-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnumber_4.c
More file actions
58 lines (38 loc) · 850 Bytes
/
number_4.c
File metadata and controls
58 lines (38 loc) · 850 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
using std::fixed;
#include <iomanip>
using std::setw;
using std::setprecision;
int main()
{
int count;
int x;
double charge;
double a;
double b;
double c;
cout<< "Enter the number of Hours:\n ";
cin >> a >> b >> c;
cout<< setw(5)<< "Car" << setw(10)<< "Hours" << setw(15)<< "Charge\n";
// cout << fixed << setprecision (1);
count = 1;
while ( count <=3 ) {
if (count == 3)
x = c;
else if (count == 2)
x = b;
else if (count == 1)
x = a;
if (x <= 3)
charge = 2000 * x;
else if (x >7)
charge = 10000;
else if (x > 3)
charge = 6000 + (x - 3) * (1000);
cout <<setw(5) << count<< setw(9) << x << setw(12)<< "Rp"<<charge <<"\n";
count = count + 1;}
return 0;
}