1.编写一个C++程序,如下述输出示例所示的那样请求并显示信息:
What is your first name? Betty Sue
What is your last name? Yewe
What letter grade do you deserve? B
What is your age? 22
Name: Yewe,Betty Sue
Grade: C
Age: 22
注意,该程序应该接受的名字包含多个单词。另外,程序将向下调整成绩,即向上调一个字母。假设用户请求A,B或C,所以不必担心D和F之间的空挡。
#if 1
#include<iostream>
using namespace std;int main()
{const int size = 20;char first_name[size];cout << "What is your first name? ";//cin >> first_name;cin.getline(first_name, size);char last_name[size];cout << "What is your last name?";cin >> last_name;char grade;cout << "What letter grade do you deserve?";cin >> grade;int age;cout << "What is your age?";cin >> age;cout << endl;cout << "Name:" << last_name << "," << first_name << endl;cout << "Grade:" << char(grade + 1) << endl;cout << "Age:" << age << endl;system("pause");return 0;
}
#endif