Question: Write a program that prompts the user to enter two characters and displys the major and status represented in the characters . The fisrt character

Write a program that prompts the user to enter two characters and displys the major and status represented in the characters . The fisrt character indicate the major and the secound in number character 1,2,3,4, which indicates weather a student is a freshman,sophomore,junior or senior

m : math

c : Computer science

Program is not running

#include #include #include using namespace std; int main() { char first, second; string result; bool b1 = true, b2 = true; cout << "Enter two characters:"; cin >> first; cin >> second; if (first == 'M') result = "Mathematics"; else if (first == 'C') result = "Computer Science"; else if (first == 'I') result = "Information Technology"; else b1 = false; if (second == '1') result = result + "Freshman"; else if (second == '2') result = result + "Sophomore"; else if (second == '3') result = result + "Junior"; else if (second == '4') result = result + "Senior"; else b2 = false; if (b1 == false && b2 == false) cout << "Invalid status code" << endl; else if (b1 == false && b2 == true) cout << "Invalid major code" << endl; else cout << result << endl; system("pause"); return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!