Help me with my loops and code!

Hello,

I'm tryin to get my code to convert my user input to upper case, while removing any extra stuff they might put in after the 'y' in 'yes.' I'm also trying to get my loop to keep appearing until they say their data they've entered is correct.

Please help me!


#include <iostream>
#include <string>
#include <string.h>

using namespace std;

int main ()
// intitalizing statements
{
int assignment_1 = 00;
int assignment_2 = 00;
int assignment_3 = 00;
int assignment_4 = 00;
int assignment_5 = 00;

char response = 'i';

// Prompt user for scores from assignments
do
{
cout << "Hello, please enter your scores for assignments 1-5, "
<< "including a space between scores.(1-100 digits)" << endl;

cin >> assignment_1;
cin >> assignment_2;
cin >> assignment_3;
cin >> assignment_4;
cin >> assignment_5;


cout << "You've entered the following are these scores correct? (Y/N) \n\n";
cout << "\tAssignment 1 = " << assignment_1 << endl << endl;
cout << "\tAssignment 2 = " << assignment_2 << endl << endl;
cout << "\tAssignment 3 = " << assignment_3 << endl << endl;
cout << "\tAssignment 4 = " << assignment_4 << endl << endl;
cout << "\tAssignment 5 = " << assignment_5 << endl << endl;

char response = toupper(response);
cin >> response;
cin.ignore(100, '\n');

if('N' == response)
{
cout << "Please reenter your scores with spaces seperating your results." << endl << endl;
}
else
{
cout << "Great, let's move forward!" << endl;
}

}while ('N' == response);

return 0;
}
1
2
char response = toupper(response);
cin >> response;
You are trying to convert input to uppercase before you read that input.
When I compile this code though, it's not running my loop! That's the part I need the most.


I want the loop to be executed if the response is equal to 'N'

What am I doing wrong,

the return message say's, "great let's move forward.
Oh. I read code completely.

1
2
3
char response = 'i';
/*...*/
char response = toupper(response);
Why do you have 2 different response variables here?
Topic archived. No new replies allowed.