Thread: c++ is boring
View Single Post
Old Sep 30, 2003 | 08:16 PM
  #7  
brtecson's Avatar
brtecson
pukimonster
 
Joined: Jun 2002
Posts: 9,967
Likes: 2
From: Milwaukee, WI
Default

well, this was actually interesting it actually took me an hour to doh:. i kept getting compiler errors. it turned out that i needed to include the <manip> thing at the top.

# include <iomanip>
# include <iostream>
using namespace std;
int main () {

float counter;
float workers;
float wage;
float hours;

counter = 0;
cout << "How many workers?" << endl ;
cin >> workers ;

while ( counter < workers ) {

cout << "Hours worked by worker #" << setprecision (0) << fixed << counter + 1 << "?" << endl;
cin >> hours;
cout << "What is the wage of worker #" << counter + 1 << "?" << endl;
cin >> wage;

if ( hours <= 40)
cout << "The salary is $" << setprecision (2) << fixed << wage * hours << endl;

else
cout << "The salary is $" << setprecision (2) << fixed << (wage*40) + (hours - 40)*(wage*1.5) << endl;

counter += 1; }


return 0;

}

Reply