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 )
{
}
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.
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.
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.