欢迎来到天天文库
浏览记录
ID:38225028
大小:19.07 KB
页数:6页
时间:2019-05-26
《实验二 预处理和语句》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、实验二预处理和语句【实验目的】1、熟悉并掌握使用文件包含命令;2、熟悉并学习使用条件编译命令;3、掌握选择语句;4、掌握循环语句;【实验内容】1、编写一个程序,输入某雇员的每周工作时间(以小时计)和每小时的工资数,计算并输出他的工资。若雇员周工作小时超过40小时,则超过部分按原工资的1.5倍的加班工资来计算。若雇员每周工作小时超过60小时,则超过60的部分按原工资的3倍的加班工资来计算,而40到50小时的工资仍按照原工资的1.5倍的加班工资来计算。•要求有输入提示和输出提示,如要输入雇员的工作时间和每小时的工资值时
2、,可以提示:“Pleaseinputemployee’sworktimeandwage_per_hour:”输出时,提示:“Theemployee’swage:”;#includeusingnamespacestd;intmain(){floathour,wage_per_hour,wage;cout<<"Pleaseinputemployee'sworktimeandwage_per_hour:"<>hour>>wage_per_hour;if(hour<=40)wage=
3、hour*wage_per_hour;if(hour>40&&hour<=60)wage=(hour-40)*1.5*wage_per_hour+40*wage_per_hour;if(hour>60)wage=(hour-60)*3*wage_per_hour+20*1.5*wage_per_hour+40*wage_per_hour;cout<<"Theemployee'swage:"<4、一天是星期几。例如,如果用户输入2005和6,表示2005年1月1日是星期六,程序应输出如下内容:January1,2005isSaturday…December1,2005isThursday•用函数intComputeDay(intyear,intday)计算星期;•在main函数完成用户输入和输出工作;#include#includeusingnamespacestd;intComputeDay(intyear,intday){inti=0,j=0,flag=0;strin5、gfirst_day[12];intDay[12]={31,28,31,30,31,30,31,31,30,31,30,31};if(year%400==06、7、(year%4==0&&year%100!=0))Day[1]=29;stringmonth[12]={"January","February","March","April","May","June","July","August","September","October","November","December"};stringweek[7]={"S8、unday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};first_day[0]=week[day];for(i=0;i9、[i]<<"1,"<>year;cout<<"Pleaseinputthefirstdataofthisyear:"<>day;ComputeDay(year,day);return0;}3、编写贷款分期偿还程序。一笔贷款的月还款包含偿还本金和偿还利息。月利息可以通过月利率乘以余额(剩余本金)来计算,于是月偿还金额就10、等于月还款额减去月利息。•要求用户输入贷款额、贷款年限和利率,程序输出分期还款的计划。•如果输入贷款额度10000美元、期限1年和利率7%,程序应该输出:LoadAmount:10000NumberofYears:1AnnualInterestRate:7%MonthlyPayment:865.26TotalPayment:10381.21Payment#I
4、一天是星期几。例如,如果用户输入2005和6,表示2005年1月1日是星期六,程序应输出如下内容:January1,2005isSaturday…December1,2005isThursday•用函数intComputeDay(intyear,intday)计算星期;•在main函数完成用户输入和输出工作;#include#includeusingnamespacestd;intComputeDay(intyear,intday){inti=0,j=0,flag=0;strin
5、gfirst_day[12];intDay[12]={31,28,31,30,31,30,31,31,30,31,30,31};if(year%400==0
6、
7、(year%4==0&&year%100!=0))Day[1]=29;stringmonth[12]={"January","February","March","April","May","June","July","August","September","October","November","December"};stringweek[7]={"S
8、unday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};first_day[0]=week[day];for(i=0;i9、[i]<<"1,"<>year;cout<<"Pleaseinputthefirstdataofthisyear:"<>day;ComputeDay(year,day);return0;}3、编写贷款分期偿还程序。一笔贷款的月还款包含偿还本金和偿还利息。月利息可以通过月利率乘以余额(剩余本金)来计算,于是月偿还金额就10、等于月还款额减去月利息。•要求用户输入贷款额、贷款年限和利率,程序输出分期还款的计划。•如果输入贷款额度10000美元、期限1年和利率7%,程序应该输出:LoadAmount:10000NumberofYears:1AnnualInterestRate:7%MonthlyPayment:865.26TotalPayment:10381.21Payment#I
9、[i]<<"1,"<>year;cout<<"Pleaseinputthefirstdataofthisyear:"<>day;ComputeDay(year,day);return0;}3、编写贷款分期偿还程序。一笔贷款的月还款包含偿还本金和偿还利息。月利息可以通过月利率乘以余额(剩余本金)来计算,于是月偿还金额就
10、等于月还款额减去月利息。•要求用户输入贷款额、贷款年限和利率,程序输出分期还款的计划。•如果输入贷款额度10000美元、期限1年和利率7%,程序应该输出:LoadAmount:10000NumberofYears:1AnnualInterestRate:7%MonthlyPayment:865.26TotalPayment:10381.21Payment#I
此文档下载收益归作者所有