# A little bit of help with this one please?

This topic is 4058 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have the following thing that I'm trying to help my sister with, but I have no clue how to tell her do it here it is: Write a program that displays a menu with the following choices to the user. A - Find the largest # with a known quantity of numbers B - Find the smallest # with an unknown quantity of numbers C - Quit Please enter your choice ___ This menu needs to be repeatedly displayed until the user chooses to quit. If A is chosen, prompt the user for the quantity of numbers they wish to answer. Use a for loop to read these and display the largest. If B is chosen, prompt the users for numbers until they enter the # -99 to signal they are done. Find and display the smallest number entered. The code should be in C++ using MVS (Microsoft Visual Studio 2005). I use Dev C++, but my sister uses MVS. I just like DEV C++ better, but my sister uses MVS for school because her instructor says it is a dominate IDE. Is there an easy way to come up with the code for this? If someone could do the code and/OR sort of explain it so that I can explain it to her when she figures it out then that would be great. I'm a novice myself, but she is struggling with hers as well. Thanks in advance. Ben [Edited by - benslancer on November 7, 2006 5:04:38 PM]

##### Share on other sites
We usually don't provide the answers to homework assignments here, because that kind of beats the purpose of homework. What we can do, is to answer as many questions you or she have, but they have to be specific(not "hand me over the code please"). Btw, you don't mention what language is this for.

##### Share on other sites
I won't give you the answer either, but try this out to figure out the problem. Write down a list of numbers and then go to your sister and read them out one number at a time. After each individual number you read out, have her tell you which is biggest number you read up to that point. The human way of doing this is virtually identical to the way a computer would do it. Write down in english how she found the largest number and then convert that english statement to code.

##### Share on other sites
You would think when they post homework they wouldn't post the exact homework question. "Hint" is always a huge give away.

First you need to make a loop that controls your menu, I would suggest looking up the do/while loop.

Next you need to respond to the answers they give you, "if" statements might help here.

Finally you need to loop through the number of times they requested, might try a "for" loop here, and you need to check for each answer so another "if" could be the trick.

theTroll

##### Share on other sites
Quote:
 Original post by mikemanWe usually don't provide the answers to homework assignments here, because that kind of beats the purpose of homework. What we can do, is to answer as many questions you or she have, but they have to be specific(not "hand me over the code please"). Btw, you don't mention what language is this for.

The code is for C++ I guess the code is entered the same in both programs, but I have no idea how to use MVS, LOL. Anyway, it is not her homework assignment. It is an individual assignment that each student had to do and everyone got a different one. She basically has to solve it and explain how and why she did it. I can't even figure out what I just did. Here is what I go, but I'm not even sure if I am inputting everything that I need to do this. Hre is what I have so far which may be totally wrong:

#include <iostream>

using namespace std;

const int SENTINEL = -99;

int main()

{

cout << " A - Find the largest # with a known quantity of numbers "
<< " B - Find the smallest # with an unknown quantity of numbers "
<< " C - Quit "
if (A int

return 0;

}

I got the following message when I tried to compile it, but like I said I may totally be off on trying to figure this out. Here they are:

in function 'int main()':
expected ';' before "endl"
'A' undeclared (first use this function)
(Each undeclared identifier is reported only once for each function it appears in.)
expected '|' before "int"

I'm not sure what I just tried to do. I'm just taking a UNIX/Linux Intro class and she is supposed to be the smart one in the level 2 programming class. I will keep trying, but what other help could you all offer?

Ben

##### Share on other sites
if (A int

What is that? A is undefined, the if doesn't do anything, and there is no closing bracket.

Also,
<

##### Share on other sites
In addition to the strange "if(A int" in there that the AP above mentioned, you want to take a closer look at how you're positioning your quote marks on this line:

<< " Please enter your choice << " endl;

##### Share on other sites
what you posted looks like only half of a copy/paste job from elsewhere on the interdoom. the use of the word SENTINEL for example sounds suspicious from someone just starting out. but whatevs...could just be from your text

you should perhaps try following the advice of others and working out the algorithm of how you, the human, solve the problem.

[EDIT: removed un-necessary harshness...]

-me

##### Share on other sites
Quote:
 Original post by Palidinewhat you posted looks like only half of a copy/paste job from elsewhere on the interdoom. the use of the word SENTINEL for example sounds suspicious from someone just starting out. but whatevs...could just be from your textyou should perhaps try following the advice of others and working out the algorithm of how you, the human, solve the problem.[EDIT: removed un-necessary harshness...]-me

Sentinel was in her textbook and i think it had something to do with a loop or something. I'll have to look again when I get home. I cut and pested the code from my Dev C++ program which I downloaded from bloodshed.net and I figured that I would stop at that point after the A to see if I was even doing anything right. Along with trying to help her out, I'm trying to get a jumpstart on understanding all of this stuff. I know that I used sentinel for something, but not sure if it was the right situation or not. I will look again and post what the book used it for.

Ben

##### Share on other sites
ok in my confusion, I read that sentinel was used as part of an equation to end a data set. The book says "Suppose the number -999 marks the end of the data. then in the code I see the following:

using namespace;
const int SENTINEL = -999;
int main()

So I put that in there thinking that since the value goes to -99 then that would be a similar situation, but from what you all are saying , I'm still way off.I know what I want to do, but getting it done is the part where I'm stuck on stupid, LOL. Any additional help, this is still all greek to me; I mean I'm still learning more about Red Hat Fedora, but I would like to learn more about programming. Besides, she had to trun her work in today at 2, so I'm not sure if she got it or not, but thanks for your help anyway. What help can you all give me now. She said something about I need to put in a cin >> number but I'm not quite sure what it is for.

Ben

##### Share on other sites
For Beginners. It's at the top of the forum list for a reason.

##### Share on other sites

This topic is 4058 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.