Java
Java
Java
// TASK 1(i): enum constant values and fields come here [6 marks]
// Complete the enum declaration in Availability class using the data stated in
Table 1
M("Morning",8.00d,12.00d),
A("Afternoon",13.00d,18.00d),
N("Night",19.00d,23.00d);
// TASK 2(i): Modify if..else statement below to display starthour and endhour for
every session. [6 marks]
if ((time.session="Morning")) {
} else if ((time.session.equals="Afternoon")) {
} else if ((time.session.equals="Night")) {
}
}
import java.util.ArrayList;
}
public String getName() {
return name;
}
doctor.display();
// TASK 5(i): Modify the following codes to display the medication list, calculate
and display the medicine total price, consultation fee and total cost (medicine +
consultation fee) [10 marks]
payableCost=totalprice + consultationFee;
System.out.printf("MEDICINE : RM%.2f\n",totalprice );
System.out.printf("CONSULTATION FEE : RM%.2f\n",consultationFee() );
System.out.printf("TOTAL : RM%.2f\n",payableCost );
if (age>=65)
{
double totalDiscount=payableCost*OLD_CITIZEN;
payableCost=payableCost-totalDiscount;
System.out.printf("TOTAL AFTER OLD CITIZEN DISCOUNT : RM%.2f\
n",payableCost );
}
}
}
import java.util.ArrayList;
import java.util.Scanner;
medication.add(m1);
medication.add(m2);
medication.add(m3);
medication.add(m4);
medication.add(m5);
doctorlist.add(dr1);
doctorlist.add(dr2);
doctorlist.add(dr3);
// End of TASK 6
String name;
String hp;
String add;
String date = "";
double time = 0.0;
int age=0;
do {
System.out.println("\n******** KLINIK MESRA ********");
System.out.println("1. Consultation Detail");
System.out.println("2. Medication Details");
System.out.println("3. Payment Detail");
System.out.println("4. Exit");
switch (choice) {
case 1:
System.out.println("******** Consultation
Detail ********");
System.out.println();
System.out.print("Enter date (dd/mm/yy): ");
date = input.next();
System.out.print("Enter time (24hour
format):");
time = input.nextDouble();
System.out.println();
app = new Consultation(date, time);
pt = new Patient(name, add, hp,age,app);
int pick;
System.out.println("Doctor Detail:");
System.out.println();
// TASK 7(i): Complete the body of 'if statements' below to invoke method display
info based on Doctor's availability, invoke methods meetDr() and consutSet() once
the condition is met. [6 marks]
break;
case 2:
System.out.println("LIST OF MEDICATION
");
System.out.println("Medication\t\t\t\
tDescription\t\t\tPrice(RM)");
String buy;
int qty=0;
System.out.print("\n How many type of
medicine?: ");
medicNum = input.nextInt();
if
(medic.getID().equals(buy)) {
pt.buyMedication(medic);
medic.setQty(qty);
break;
case 3:
System.out.println("<<<< PAYMENT DETAIL
>>>>\n");
pt.display();
break;
default:
System.out.println("Thank you for
using our system");
break;
}