-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathex6.cpp
More file actions
43 lines (33 loc) · 745 Bytes
/
Copy pathex6.cpp
File metadata and controls
43 lines (33 loc) · 745 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
CPSC 121-0X
Paul De Palma
depalma
Example 6
*/
//formatting output, while loop
#include <iostream>
#include <iomanip> //notice this line
using namespace std;
const int WEEKS = 4;
int main()
{
double hours, rate, pay;
int i;
i = 0;
cout << setprecision(2) << fixed; //show decimal point, two digits precision
while (i < WEEKS)
{
hours = 0.0;
rate = 0.0;
pay = 0.0;
cout << "How many hours did your work in week " << i + 1 << endl;
cin >> hours;
cout << "How much did you get paid per hour in week " << i + 1 << endl;
cin >> rate;
pay = hours * rate;
//8 spaces from the space after the colon to the dollar sign
cout << "Week " << i + 1 << ": " << setw(8) << "$" << pay << endl;
i++;
}
return 0;
}