// ***************************************************************** // Author: Zhixiang Chen // Class: CSCI/CMPE 1170, Spring 2009 // Lab Optional 1: character and string comparisions, conditional operator // Date: January 17, 2009 // Comment: The code here is meant to be revised. // //----------------------------------------------------------------- // Lab Exercise 12: // // This lab exercise is to play with character and string comparisions // and conditional expressions // // First, use character to decide two options of the program: // option A to play with four seasons; option B for testing conditional // expressions. // // Compile and run your program. When everything is fine, // print your .cpp file and turn it to me or the TA. // ***************************************************************** #include < iostream > #include #include < string > #include < cstring > #include < cmath> #include #include using namespace std; int main( ) { //variable declaration double score; //var to store score for the class char option; //to decide the option string month; //var to store month name //ask the user to enter option cout<<"Want to four seaons or grading?\n "; cout<<" 'a' or 'A' for four seasons, 'b' or 'B' for grading => "; cin>>option; //decide the option if (option == 'a' || option == 'A') //character comparison { //ask for month cout<<" Enter month ==> "; cin>>month; //decide four seasons if (month == "January" || month == "February" || month =="March") //string comparison cout< "; cin>>score; cout<< " You grade for the class is "; cout<< score >= 90 ? 'A' : //get 'A' ( //this part is for you: decide other grades using the same as Lab 11. ) } else { //This part is for you: add exception handling } //well done and exit return 0; }