-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTugas 04b - Harga Karcis Parkir.CPP
100 lines (94 loc) · 1.88 KB
/
Tugas 04b - Harga Karcis Parkir.CPP
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
int jenis;
int total;
int jam_in;
int jam_out;
int durasi;
long mobil1= 100000;
long mobil2= 200000;
long motor1= 200000;
long motor2= 300000;
int sepeda1= 5000;
int sepeda2= 10000;
cout << "Silakan pilih jenis kendaraan Anda"<<endl;
cout << "1. Mobil"<<endl;
cout << "2. Motor"<<endl;
cout << "3. Sepeda"<<endl;
cout << "Jenis kendaraan: ";
cin>>jenis;
cout<<endl;
switch (jenis)
{
case 1:
{
cout << "Mobil"<<endl;
cout << "Jam Masuk: ";
cin>>jam_in;
cout << "Jam Keluar: ";
cin>>jam_out;
durasi= jam_out - jam_in;
cout << "Lama Parkir: "<<durasi;
cout<<endl;
total = mobil1 + mobil2;
if(durasi<= 2)
{
total= mobil1 + 0;
}
if(durasi > 2 && durasi <= 12)
{
total= mobil1 + (mobil2*(durasi-2));
}
cout << "Total Pembayaran: "<<total;
}
break;
case 2:
{
cout << "Motor"<<endl;
cout << "Jam Masuk: ";
cin>>jam_in;
cout << "Jam Keluar: ";
cin>>jam_out;
durasi= jam_out - jam_in;
cout << "Lama Parkir: "<<durasi;
cout<<endl;
total = motor1 + motor2;
if(durasi<= 2)
{
total= motor1 + 0;
}
if(durasi > 2 && durasi <= 12)
{
total= motor1 + (motor2*(durasi-2));
}
cout << "Total Pembayaran: "<<total;
}
break;
case 3:
{
cout << "Sepeda"<<endl;
cout << "Jam Masuk: ";
cin>>jam_in;
cout << "Jam Keluar: ";
cin>>jam_out;
durasi= jam_out - jam_in;
cout << "Lama Parkir: "<<durasi;
cout<<endl;
total = sepeda1 + sepeda2;
if(durasi<= 2)
{
total= sepeda1 + 0;
}
if(durasi > 2 && durasi <= 12)
{
total= sepeda1 + (sepeda2*(durasi-2));
}
cout << "Total Pembayaran: "<<total;
}
break;
}
getch();
}