close

//---------------------------------------------------------------------------
/****************************************************************************
練習6-5:寫一個程式可輸入工作時數和每小時薪資,算出每周的薪水。若是超過40小 *
         時的部份,則應乘上1.5倍(算是加班的鐘點費)。                 *
****************************************************************************/
#include <iostream>
#include <string>
//---------------------------------------------------------------------------
int workHour;
int hourSalary;
int weekSalary;

int main(int argc, char* argv[])
{
        std::cout << "Enter work hours and salary per/hour, system will tell "
                  << "you how much \nsalary you get this week: \n";

        std::cin >> workHour;
        std::cin >> hourSalary;

        if (workHour <= 40)
        {
          weekSalary = workHour * hourSalary;
          std::cout << "You get NT $" << weekSalary << " this week";
        }

        else
        {
          weekSalary = 40 * hourSalary + (workHour-40) * 1.5 * hourSalary;
          std::cout << "You can get NT $" << weekSalary << " this week";
        }

        std::system("pause");
        return 0;
}
//---------------------------------------------------------------------------


題目來源:C++風格與藝術 第二版 Steve Oualline 著 黃吉霈 編譯
答案來源:自我撰寫(不保證正確喔)

arrow
arrow
    全站熱搜

    jumbowind 發表在 痞客邦 留言(0) 人氣()