-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4_1.cpp
52 lines (44 loc) · 1.02 KB
/
4_1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <iostream>
#include <string>
int main()
{
using namespace std;
string firstName;
string lastName;
char grade;
int age;
cout << "What is your first name? ";
while(!getline(cin, firstName))
{
cout << "Error! Please re-enter your first name: ";
cin.clear();
cin.sync();
}
cout << "What is your last name? ";
while(!getline(cin, lastName))
{
cout << "Error! Please re-enter your last name: ";
cin.clear();
cin.sync();
}
cout << "What letter grade do you deserve? ";
while(!(cin >> grade) || ('A' > grade) || ('Z' < grade))
{
cout << "Error! Please re-enter your grade: ";
cin.clear();
cin.sync();
}
char finalGrade = grade + 1;
cout << "What is your age? ";
while(!(cin >> age) || (0 > age))
{
cout << "Error! Please re-enter your age: ";
cin.clear();
cin.sync();
}
cout << "Name: " << lastName << ", " << firstName << endl;
cout << "Grade: " << finalGrade << endl;
cout << "Age: " << age << endl;
// system("pause");
return 0;
}