-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathHospital.java
98 lines (86 loc) · 2.4 KB
/
Hospital.java
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
import java.util.*;
class Patient {
String pid, name, age, gender, address, mobnumber;
void getData() {
Scanner sc = new Scanner(System.in);
pid = sc.nextLine();
sc.nextLine();
name = sc.nextLine();
sc.nextLine();
age = sc.nextLine();
sc.nextLine();
gender = sc.nextLine();
sc.nextLine();
address = sc.nextLine();
sc.nextLine();
mobnumber = sc.nextLine();
}
void displayData() {
System.out.println(pid);
System.out.println(name);
System.out.println(age);
System.out.println(gender);
System.out.println(address);
System.out.println(mobnumber);
}
}
class In_patient extends Patient {
String roomnumber;
double consultationfee, testfee;
String doa, dischargedate;
int numberofdays;
double roomrent;
void getData() {
super.getData();
Scanner sc = new Scanner(System.in);
roomnumber = sc.nextLine();
sc.nextLine();
consultationfee = sc.nextDouble();
sc.nextLine();
testfee = sc.nextDouble();
sc.nextLine();
doa = sc.nextLine();
sc.nextLine();
dischargedate = sc.nextLine();
sc.nextLine();
numberofdays = sc.nextInt();
sc.nextLine();
roomrent = sc.nextDouble();
}
void displayData() {
super.displayData();
System.out.println(roomnumber);
System.out.println(consultationfee);
System.out.println(testfee);
System.out.println(doa);
System.out.println(dischargedate);
System.out.println(numberofdays);
System.out.println(roomrent);
}
}
class Bill extends In_patient {
String dateofbill;
double totalamt;
void getData() {
super.getData();
Scanner sc = new Scanner(System.in);
System.out.print("Enter date of bill");
dateofbill = sc.nextLine();
}
void displayData() {
super.displayData();
System.out.println(dateofbill);
}
void calculateTotalBillAmount() {
totalamt = consultationfee + testfee + (numberofdays * roomrent);
System.out.println("Total amt is : " + totalamt);
}
}
class Hospital {
public static void main(String args[]) {
Bill bill1 = new Bill();
bill1.getData();
bill1.displayData();
bill1.calculateTotalBillAmount();
}
}