Professor 100 Yuan/hour Associate Professor 80 Yuan/hour lecturer 60 yuan/hour TA 40 yuan/hour
Enter the teacher's name, teaching hours, and output the teacher's remuneration
#include <iostream> #include <iomanip> #include <string>using namespace std;int Main () { int salary; class teacher{ public: string name; string title; int time; }; teacher T1; cout<< "Please enter: Name and title of teaching hours" <<endl; cin>>T1.name>>T1.title>>T1.time; if (String (t1.title) ==string ("Professor")) { salary=t1.time*100; } else if (String (T1.title) = = String ("Associate Professor")) { salary=T1.time*80; } &Nbsp; else if (String (t1.title) ==string ("lecturer")) { salary=t1.time*60; } else if (String (t1.title) ==string ("Ta") { salary= t1.time*40; } else { cout<< "Your input is wrong"; return 0; } cout<<T1.name<<T1.title<< " " << "Your remuneration is" <<salary<< "Yuan" <<endl; return 1;}
This topic learns the use of the string type and string (), using this to #include<string>
This article from "Blue Domain Creeps" blog, declined reprint!
The eighth question of C + + exercises