In: Computer Science
In C++ Write a program which asks the user his/ her major, stores it in a variable called major, then asks What is your GPA? and stores it in a variable called gpa. Next, ask a question based on the answers from the previous two questions. For example: What is your major? computer science What is your gpa? 3.52 computer science is very hard; why do you think you have a gpa of 3.52?
#include <iostream>
#include <string>
using namespace std;
int main()
{
string major;
float gpa;
cout <<"What is your major? "<< endl;
getline (cin,major);
cout<<"What is your gpa? "<< endl;
cin>> gpa;
cout<<major<<" is very hard; why do you think you have
a gpa of "<<gpa<<"?" <<endl;
return 0;
}
Code:
Output: