// Declare variables to store inputs
// Declare an array of strings representing each day
// Start for loop
// -- Ask user for variable input
// -- Start while loop, while input isn't valid
// -- -- Ask for input again
// -- End while loop
// End for loop
// Write simple algorithm to work out highest number
// Print out the string array at the index of that number - 1
Make sure the user doesn't input something stupid. Presumably, the only numbers that should be entered are between 1 and 7, yes?
Don't forget, arrays start at index 0, if a user enters "1", array index 1 would actually be Tuesday, not Monday. Don't forget to subtract one from the entered number to get the correct day.
thanks for replies. ihutch pls I need codes as I no nothing about c++ and I have deadline Friday. if I don't get it , I won't be allowed to partake in subsequent classes. pls
thanks
Ok, so the inputs are fine but you haven't been clear on the specifics. Do you want the numbers input to be only between 1 and 7? How else are they going to correspond to days of the week if not?
One other thing concerning the inputs; why not make them an array? This would make your input loop so much simpler.
1 2 3 4 5 6 7 8
constint MAX_INPUTS;
int inputs[MAX_INPUTS];
for (int i=0; i < MAX_INPUTS; i++)
{
cout << "Please enter a number: ";
cin >> inputs[i];
}
As I said, you may want to include some validation that checks what numbers get entered.
Having that array will make finding the largest number super easy.
1 2 3 4 5 6 7
int largest=0;
for (int j=0; j< MAX_INPUTS; j++)
{
// Check to see number at that array is larger than largest int
// then assign accordingly
}
Also, your array of days:
string Days[7] = {"Sunday", /*etc*/};
Much happier to help out when you have a go yourself. Haven't given you complete answers there because it's best you learn yourself but hopefully that'll nudge you in the right direction.