writing code

Could I get some help writing this program. It has to follow the menu. I don't have a clue to start and the tutorials I have watched just confused me more. Thank you in advance.


#include <string>
#include <iostream>

using namespace std;

int main ()
{
char menuInput;
char largeEntryInput,largeEntryNumber,largeNextNumber; //declare varibles

while (menuInput != "#")

cout << "A - Find the largest # with a known quantity of numbers."<< endl;
cout << "B - Find the smallest # with an unknown quantity of numbers"<< endl;
cout << "C - Quit"<< endl; //
cout << "Please enter your choice ";
cin >> menuInput; //get menu input
if (menuInput == "C")
EOF;
{
while (menuInput != "#")
if (menuInput == "A")//Perform mathmatical equations to find the largest number
string laregeEntryInput; //read input
//get choice of menu
cout << "How many numbers would you like to compare?";
cin >> largeEntryNumber;// get numbers
while ( largeEntryNumber < 1 ) //start of mathmatical loop to find the largest number


while nemuInput != "#";
if (menuInput == "B")// Perform mathmatical equations to find lowest number




{
cout << "Not a valid number. Please try again." << endl;
cin >> (largeEntryNumber);
}
cout << "Please type in " << largeEntryNumber << " integer(s), separated by spaces, then press enter." << endl;
cin >> largeEntryInput;
if ( largeEntryNumber == 1 )
{
}

return 0;
Hi calvin1965,

Could you please specify as where are you confused?
As the program looks pretty staright forward. You just have to implement the required functionality.
I am sorry but we do not do home-work over here. If you have any specific questions, we would be glad to help.

Funny I think we are working on the same assignment.

My question for this is how do i go about creating the statement for greater than less than, using multiple entries without storing each entry?

For example:

12 67 76 89 76 89 63 2 67 86 32 35

are the integers entered.

I store the first integer using

cin >> num;

at this point I seem to be getting stuck, I don't know how exactly to store the next integer, to compare to the first and then compare the largest of the two integers to the next integer in the string of entered numbers.

Just wondering if I could get a hand.
You could use a vector to store the data and figure out some algorithm to check for the largest integers.
To get the max number, one thing you could do is, just declare a variable int max = 0;
Then after every input just check if the input is greater than the max. So for example, for your input, code will be something like:
1
2
3
4
5
6
7
8
9
10
int max = 0; 
while (cin>>num) {
  
   if (max < num) {

       max = num; 
   } 
 
} 
cout<<"Max number of all the input is :"<<max<<" \n"; 


So in this way, when you'll get first input as 12 then it is obviously greater than 0. So max will be 12 at this point. For 67, now max which is 12 at this point, is again less than 67 therefore now max is 67. And so on.

Hope this helps !
If you are storing input in char array then you can split the string using strtok and convert each string to an int using atoi. and then compare the same way.
Last edited on
I am not asking you to do my homework. I am asking the same question the other gentlemen did. I don't understand it.
Topic archived. No new replies allowed.