c++ loop问题

来源:百度知道 编辑:UC知道 时间:2024/05/11 19:48:09
write a program that will accept payroll information from the keyboard and then calculate and display certain paycheck information totals.

Your program should:

*

display an informative title
*

prompt the user for the number of hours worked
*

verify that the number of hours worked is greater than 0
*

prompt the user for the hourly pay rate
*

verify that the hourly pay rate is greater than 0
*

use the verified values that the user entered to calculate the gross pay, social security tax withheld, withholding tax, and net pay
*

display the various calculated values, one per line with an appropriate label.

Calculations

The Gross Pay is calculated as the sum of the wages for the first 40 (or less) hours and the overtime pay.

The Overtime Pay is calculated as 1.5 t

#include <iostream>
#include <iomanip>
using namespace std;

int main(){
double gross_pay;
double hourly_pay_rate;
int hours;
cout<<"Payment Calculating System"<<endl;
cout<<"Enter number of hours worked: ";
do{
cin>>hours;
if(hours>0) break;
else cout<<"Invalid input. Please try again."<<endl<<"Enter number of hours worked: ";
}while(1);
cout<<"Enter hourly pay rate: ";
do{
cin>>hourly_pay_rate;
if(hourly_pay_rate>0) break;
else cout<<"Invalid input. Please try again."<<endl<<"Enter hourly pay rate: ";
}while(1);
gross_pay=hourly_pay_rate*hours;
cout<<"***************************************************"<<endl;
cout<<"Your gross pay is: "<&l