forked from SWEG2012BatchSecbG4/car-rent.cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcar rent.cpp
103 lines (94 loc) · 2.56 KB
/
car rent.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
101
102
void cin_fix()
{
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
cout<<"invalid input ";
usleep(500000);
system("cls");
}
void notifications (registration *registryinfo,vehicle *vehicle_info)
{
label3:
system("cls");
title_printer("today's over dues are :");
// current date/time based on current system
time_t now = time(0);
tm *ltm = localtime(&now);
if (registry_no==1)
{
body_printer("no data");
usleep(4000000);
main();
return;
}
for (int i=0;i<registry_no;i++)
{
if ((registryinfo[i].local_date.seconds_elapsed+(registryinfo[i].duration*86400))<now && registryinfo[i].return_check==0)
{
registry_table_printer(registryinfo[i]);
}
}
label4:
cout<<"please enter the id of the receipt you wish to process or enter 0 if to return to the home screen :";
int receipt_id;
cin>>receipt_id;
if (receipt_id==0)
{
main();
return ;
}
if (receipt_id<registry_no)
{
if ((registryinfo[receipt_id-1].local_date.seconds_elapsed+(registryinfo[receipt_id-1].duration*86400))<now && registryinfo[receipt_id-1].return_check==0)
{
int overdue=((vehicle_info[(registryinfo[receipt_id-1].car_id-1)].price)*(now-(registryinfo[receipt_id-1].local_date.seconds_elapsed+(registryinfo[receipt_id-1].duration*86400))))/86400;
cout <<"\n \t \t \t ------------------------------------------------------------------------------ \n";
cout<<"\t \t \t ### overdue = "<<overdue;
cout <<"\n \t \t \t ------------------------------------------------------------------------------ \n";
body_printer("press 1 to process this receipt, or press any other key to return to the notifications window");
char user_choice;
user_choice=getch();
if (user_choice==1)
{
registryinfo[receipt_id-1].return_check=1;
title_printer("transaction completed");
body_printer ("press 1,to go to the notifications window or press any other key to return to the home screen");
char user_choice2;
user_choice2=getch();
switch(user_choice2)
{
case '1':
goto label3;
break;
default :
main();
return;
}
}
else
main();
return;
}
else
{
body_printer("no overdue");
body_printer ("press 1,to go to the notifications window or press any other key to return to the home screen");
char user_choice3;
user_choice3=getch();
switch(user_choice3)
{
case '1':
goto label3;
break;
default :
main();
return ;
}
}
}
else
{
body_printer("invalid input please try again");
goto label4;
}
}