-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask4_g8.cpp
More file actions
87 lines (60 loc) · 1.93 KB
/
Task4_g8.cpp
File metadata and controls
87 lines (60 loc) · 1.93 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
/*
FCI-Programming 1 -2018 - Assignment 2
Program Name : Cost of a long distant call , p.174 , number :1.
Last Modification Date 2/3/2018.
Author1 and ID and Group : Fares sayed hassan , 20170191 , 8.
Author2 and ID and Group : Alaa Ibrahem , 20170166 , 7.
Author3 and ID and Group : Amr Alaa , 20170187 , 7.
Author4 and ID and Group : Ali Samir , 20170172 ,7.
Teaching Assistant:
Purpose : To calculate the cost of long distant calls.
*/
int main()
{
string day;
string time;
int timeMinutes;
double timeHours;
int nMinutes;
double cost;
string auxHours;
string auxMinutes;
cout << "Enter your call minutes :" << endl;
cin >> nMinutes;
cout << "Enter the day that you started the call in .\nIt should be abbreviated like:\n mo,tu,we,th,fr,sa and su ." << endl;
cin >> day;
cin.ignore();
cout << "Enter the time you started the call at in 24 format like this 2:12 :" << endl;
getline(cin,time);
int i=0;
while(time[i]!=':'){
if(time[i]!=' '){
auxHours+=time[i];
}
++i;
}
for (int j=i+1; j<time.length();j++){
if(time[j]!=' '){
auxMinutes+=time[j];
}
}
timeHours = stoi(auxHours);
timeMinutes = stoi(auxMinutes);
timeHours += timeMinutes / 60.0;
if(( (tolower(day[0]) == 's') && (tolower(day[1]) == 'a') ) || ( (tolower(day[0]) == 's') && (tolower(day[1]) == 'u') )){
cost=nMinutes * .15;
}else {
if(timeHours >= 8 && timeHours <= 18){
cost=nMinutes * .40 ;
}
if ( (timeHours > 18 && timeHours <=24) || (timeHours >=0 && timeHours <8) ){
cost = nMinutes * .25;
}
}
cout << "The cost of your call is: " << cost << "$" <<endl;
return 0;
}