add chapter 4 Question 1

This commit is contained in:
kuoi 2022-08-25 00:37:24 +01:00
parent 9d96a504ed
commit 4ef7224ff2
1 changed files with 24 additions and 0 deletions

24
ch04/01.cpp Normal file
View 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;
}