Beruflich Dokumente
Kultur Dokumente
MACHANG CAMPUS
PREPARED BY (D1CS2404A):
NAME MATRIC NUMBER
Nur Syafiqah Bahirah binti Mohd Saipul Bahari 2020985161
Aisyah Hamizah binti Mahussin 2020964577
Nur Syazana Binti Ahmad Jefiruddin 2020977237
PREPARED FOR:
Dr. Muhammad Firdaus Mustapha
1
TABLE OF CONTENTS
1. Source code...................................................................................................................................3
2. Output.........................................................................................................................................12
2
1. Source code
i. OrderServiceApp
import java.util.Scanner;
import java.lang.String;
class OrderServiceApp{
public static void main(String []args){
try{
Scanner sc = new Scanner(System.in);
System.out.print("Date:");
String dt = sc.nextLine();
System.out.print("Quantity : ");
int qty = Integer.parseInt(sc.nextLine());
String c = sc.nextLine();
3
//COD
if(c.equalsIgnoreCase("C")){
System.out.print("Enter detailed address:");
String ad = sc.nextLine();
os[i].calcServiceTax();
os[i].print();
}
//Dine In
else if(c.equalsIgnoreCase("D")){
System.out.print("Enter table no:");
int tn = Integer.parseInt(sc.nextLine());
os[i].calcServiceTax();
if(bt.equalsIgnoreCase("Y")){
((DineIn) os[i]).calcTaxBirth();
}
else{
os[i].print();
}
4
catch (Exception e) {
//System.out.println("Something went wrong.");
System.out.println(e.getMessage());
e.printStackTrace();
}
}
}
5
ii. OrderService
6
iii. Cod
if(code == 1)
{
burgerPrice = quantity * 10;
orderPrice = burgerPrice + delCaj;
}
else if(code == 2)
{
sandwichPrice = quantity * 5;
orderPrice = sandwichPrice + delCaj;
}
else if(code ==3 )
{
7
pastaPrice = quantity * 7;
orderPrice = pastaPrice + delCaj;
}
8
iv. DineIn
public DineIn(String a, String b, String c, int d, int e,int tn, String bt)
{
super(a, b, c, d, e);
tableNo = tn;
birth = bt;
}
if(code == 1)
{
burgerPrice = 10 * quantity ;
orderPrice = burgerPrice + serviceTax;
}
else if(code == 2)
{
sandwichPrice = 5 * quantity ;
orderPrice= sandwichPrice + serviceTax;
}
else if(code ==3 )
{
pastaPrice = 7 * quantity ;
orderPrice = pastaPrice + serviceTax;
}
9
public void calcTaxBirth(){
double totalBirth;
if(birth.equalsIgnoreCase("Y")){
totalBirth = getOrderPrice() + birthdayTax; //+ rm5
System.out.println("Total price + Birthday package price : " + totalBirth);
}
}
}
10
v. Package
11
2. Output
i.
12
13
ii.
14
15
iii.
16