-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHospital_Management.cpp
More file actions
50 lines (40 loc) · 1011 Bytes
/
Hospital_Management.cpp
File metadata and controls
50 lines (40 loc) · 1011 Bytes
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
/*PROBLEM
Hospital Management — Patient Age & Category Calculation
A hospital system wants to categorize patients automatically.
Write a function that accepts date of birth and returns:
1. Age in years
2. Category: Child, Adult, Senior
Hint:
Write a helper function to calculate age from year.*/
#include<iostream>
using namespace std;
int patient_age(int birth_year, int current_year)
{
int age = current_year - birth_year;
return age;
}
int Category(int age)
{
if(age <= 18){
cout<<"Child Patient";
}
else if(age > 18 && age <= 40){
cout<<"Adult Patient";
}
else
cout<<"Senior Patient";
return 0;
}
int main()
{
int B_year, C_year, age;
cout<<"Enter your birth year:";
cin>>B_year;
cout<<"Enter current year:";
cin>>C_year;
age = patient_age(B_year,C_year);
cout<<"Patient age: " << age ;
cout<<"\nPatient Category: ";
Category(age);
return 0;
}