-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathquestion33.cpp
More file actions
63 lines (56 loc) · 1.87 KB
/
question33.cpp
File metadata and controls
63 lines (56 loc) · 1.87 KB
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
#include <iostream>
using namespace std;
int main () {
int day, network, time, length, cost;
cout << "enter day of the week (1 - 7 represents monday - sunday): ";
cin >> day;
cout << "enter network type (1-3 represents same, different and international network): ";
cin >> network;
cout << "enter time (enter four digit value in 24 hour format): ";
cin >> time;
cout << "enter length of call (in minutes): ";
cin >> length;
//between 0700 and 1900, Monday to Friday
while (time >= 0700 && time <= 1900) { //from 7am to 7pm
while (day > 0 && day < 6) { //days 1 to 5 (monday to friday)
if (network == 1) {
cost = length * 1200;
} else if (network == 2) {
cost = length * 2400;
} else if (network == 3) {
cost = length * 8200;
} else {
cout << "error";
}
}
}
//before 0700 and after 1900, Monday to Friday
while (time > 1900 && time < 0700 ) { // before 7am and after 7pm
while (day > 0 && day < 6) { // days 1 to 5 (monday to friday)
if (network == 1) {
cost = length * 800;
} else if (network == 2) {
cost = length * 1400;
} else if (network == 3) {
cost = length * 5200;
} else {
cout << "error";
}
}
}
//Saturday and Sunday
while (day > 5 && day < 8) { //days 6 and 7 (saturday, sunday)
if (network == 1) {
cost = 0;
} else if (network == 2) {
cost = length * 600;
} else if (network == 3) {
cost = length * 4000;
} else {
cout << "error";
}
}
//Show total cost
cout << "your total cost is: GHS " << cost;
return 0;
}