/*
* Copyright (c) 2014, 烟台大学计算机学院
* All rights reserved.
* 文件名称:test.cpp
* 作 者:曾晓
* 完成日期:2014年 10 月 16日
* 版 本 号:v1.0
*
* 问题描述:计算一周的薪水:当hour>=40时,w=40*rate+1.5*rate*(hour-40);否则,w=rate*hour。
输入描述:输入hour,rate.
程序输出:对应的W值。
*/
clude <iostream>
using namespace std;
int main()
{
double rate ,hour ,w;
cout <<"请输入这周小贺上班的时间:";
cin >>hour>>rate;
if (hour<=40)
w=hour*rate;
else
w=40*rate +1.5*(hour-40)*rate;
cout <<w;
return 0;
}
运行结果:
知识点总结:定义了新的变量,学会运用if else 。
学习心得: 昨晚在纸上写的大体框架,还是存在细节错误。