Kamis, 27 Maret 2014

Ebook chapter 5 Problem Solving and Program Design in C

  •   5.4 Figure 5.5 Using a for Statement in a Counting Loop

#include <cstdlib>
#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

 

Anita © 2010

Blogger Templates by Splashy Templates