-
Notifications
You must be signed in to change notification settings - Fork 0
/
age calc.cpp
49 lines (41 loc) · 926 Bytes
/
age calc.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
#include<iostream>
using namespace std;
class persondata{
int birthmonth,birthyear;
float cm,meters;
int currentmonth,currentyear;
int agey,agem;
public:
void getdata(){
cout<<"Enter Your Birth Year:";
cin>>birthyear;
cout<<"\nEnter Your Birth Month:";
cin>>birthmonth;
cout<<"\nEnter The Current Month:";
cin>>currentmonth;
cout<<"\nEnter The Current Year:";
cin>>currentyear;
cout<<"\nEnter Your Height in Meters:";
cin>>meters;
}
void calc(){
int m;
cm=meters*100;
agey=currentyear-birthyear;
m=currentmonth-birthmonth;
if(m<0){
agey=currentyear-birthyear+m;
agem=12+m;}
}
void putdata(){
cout<<"\nYour Age is "<<agey<<" Years And "<<agem<<" Months and Height in Centimeter is "<<cm;
}
};
int main()
{
persondata per;
per.getdata();
per.calc();
per.putdata();
return 0;
}