add chapter 4 Question 1
This commit is contained in:
parent
9d96a504ed
commit
4ef7224ff2
1 changed files with 24 additions and 0 deletions
24
ch04/01.cpp
Normal file
24
ch04/01.cpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
# include <iostream>
|
||||
# include <string>
|
||||
using namespace std;
|
||||
|
||||
int main(){
|
||||
string f_nm, l_nm;
|
||||
char grad[5] = "ABCD";
|
||||
int year, i;
|
||||
char t;
|
||||
cout << "What is your first name? ";
|
||||
getline(cin, f_nm);
|
||||
cout << "What is your last name? ";
|
||||
getline(cin, l_nm);
|
||||
cout << "What letter grade do you deserve? ";
|
||||
cin >> t;
|
||||
for (i=0; t != grad[i]; i++);
|
||||
i++;
|
||||
cout << "What is your age? ";
|
||||
cin >> year;
|
||||
cout << "Name: " << l_nm << ", " << f_nm << endl;
|
||||
cout << "Grade: " << grad[i] << endl;
|
||||
cout << "Age: " << year << endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue