5.4 Figure 5.5 Using a for Statement in a Counting Loop
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int count_emp, number_emp;
float rate,pay,total_pay=0.0,hours;
cout<<"Enter number of employees> ";
cin>>number_emp;
for (count_emp=0;count_emp < number_emp; count_emp += 1) {
cout<<"Hours> ";
cin>>hours;
cout<<"Rate> $";
cin>>rate;
pay= hours*rate;
cout<<"Pay is= $ "<< pay<<endl;
total_pay=total_pay+pay;
}
cout<<"All employees processed"<<endl;
cout<<"Total payroll is " <<total_pay<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
RUN :
0 komentar:
Posting Komentar