The eighth question of C + + exercises

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.