forked from ASD-ADF/ASD_Task_2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
171 lines (152 loc) · 3.77 KB
/
Copy pathmain.cpp
File metadata and controls
171 lines (152 loc) · 3.77 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/**
KELAS : IF-39-01
KELOMPOK : 10
NAMA(NIM) : [ANJAR AFRIZAL][1301154239] , [FAHRU ADI RAMADHAN][1301154141] , [FAUZI KURNIAWAN][1301154267] , [REGITA RATIH P][1301150435]
**/
#include <iostream>
#include <windows.h>
#include <conio.h>
#include "orang.h"
#include "tanggal.h"
using namespace std;
orang o1, o2;
string nama;
int tgl, bln, thn, pilihan, tgledit,b;
bool cek;
void mainmenu();
void rubah_tanggal();
void tampil_data();
int main()
{
cout << "Hello!" << endl;
cout << "masukkan nama orang 1: ";
cin>>nama;
cout << "masukkan tanggal lahir orang 1: ";
cin>>tgl;
cout << "masukkan bulan lahir orang 1: ";
cin>>bln;
cout << "masukkan tahun lahir orang 1: ";
cin>>thn;
o1 = create_orang(nama, tgl,bln,thn);
cek = cek_tanggal(o1.tgl_lahir);
if (cek == true)
{
cout << endl;
show_orang(o1);
cout << endl;
}
else
{
cout << "maaf input tanggal lahir anda salah, silahkan ulangi lagi"<<endl;
cout << endl;
return main();
}
cout << "masukkan nama orang 2: ";
cin>>nama;
cout << "masukkan tanggal lahir orang 2: ";
cin>>tgl;
cout << "masukkan bulan lahir orang 2: ";
cin>>bln;
cout << "masukkan tahun lahir orang 2: ";
cin>>thn;
o2 = create_orang(nama, tgl,bln,thn);
cek = cek_tanggal(o2.tgl_lahir);
if (cek == true)
{
cout << endl;
show_orang(o2);
cout << endl;
}
else
{
cout << "maaf input tanggal lahir anda salah, silahkan ulangi lagi"<<endl;
cout << endl;
return main();
}
cout<< "selisih hari : "<<selisih_hari(o1.tgl_lahir,o2.tgl_lahir)<<" hari"<<endl;
cout<< endl;
getch();
system("cls");
mainmenu();
return 0;
}
void mainmenu ()
{
cout << "Main Menu" <<endl;
cout << "1. Edit Tanggal Lahir"<<endl;
cout << "2. Tampil Data orang & selisih Tanggal lahir"<<endl;
cout << "3. Keluar"<<endl;
cout << endl;
cout << "Masukkan Pilihan: ";
cin >> pilihan;
switch (pilihan)
{
case 1 :
rubah_tanggal();
break;
case 2 :
tampil_data();
break;
case 3 :
cout << "Terima Kasih"<<endl;
break;
}
}
void rubah_tanggal()
{
cout << "pilih data tanggal lahir yang akan dirubah 1=orang1 2=orang2 : ";
cin >> tgledit;
if (tgledit == 1)
{
cout << "masukan tanggal : ";
cin >> tgl;
cout << "masukan bulan : ";
cin >> bln;
cout << "masukan tahun : ";
cin >> thn;
edit_tanggal(o1.tgl_lahir, tgl, bln, thn);
cout << endl;
show_orang(o1);
cout << endl;
cout << "tekan enter"<< endl;
getch();
system("cls");
mainmenu();
}
else if (tgledit == 2)
{
cout << "masukan tanggal : ";
cin >> tgl;
cout << "masukan bulan : ";
cin >> bln;
cout << "masukan tahun : ";
cin >> thn;
edit_tanggal(o2.tgl_lahir, tgl, bln, thn);
cout << endl;
show_orang(o2);
cout << endl;
cout << "tekan enter "<<endl;
getch();
system("cls");
mainmenu();
}
else
{
cout << "maaf inputan anda salah, silahkan ulangi lagi";
rubah_tanggal();
}
}
void tampil_data()
{
cout << "data orang pertama"<<endl;
show_orang(o1);
cout << endl;
cout << "data orang kedua"<<endl;
show_orang(o2);
cout << endl;
cout<< "selisih hari : "<<selisih_hari(o1.tgl_lahir,o2.tgl_lahir)<<" hari"<<endl;
cout<< endl;
getch();
system("cls");
mainmenu();
}