forked from rocktimsaikia/School-Java-Projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRESTURANT_BILL_EXERCISE.java
More file actions
35 lines (33 loc) · 1.11 KB
/
RESTURANT_BILL_EXERCISE.java
File metadata and controls
35 lines (33 loc) · 1.11 KB
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
import java.util.Scanner;
public class RESTURANT_BILL_EXERCISE {
public static void main(String args[]){
double meal_price,tax,tip,total;
Scanner input = new Scanner(System.in);
Payment pay = new Payment();
System.out.print("\nEnter Meal Price : ");
meal_price = input.nextDouble();
tax = pay.getTax(meal_price);
tip = pay.getTip(meal_price);
total = pay.getTotal(meal_price,tax,tip);
pay.displayBill(meal_price,tax,tip,total);
}
}
class Payment{
double TAX_RATE = 0.05;
double TIP_PERCENT = 0.15;
double getTax(double mealPrice){
return mealPrice*TAX_RATE;
}
double getTip(double mealPrice){
return mealPrice*TIP_PERCENT;
}
double getTotal(double mealPrice,double tax,double tip){
return mealPrice+tax+tip;
}
void displayBill(double mealPrice,double tax,double tip,double total){
System.out.println("\nTHE BILL :");
System.out.println("\tTAX AMOUNT..............................$"+tax);
System.out.println("\tTIP AMOUNT..............................$"+tip);
System.out.println("\tTOTAL BILL AMOUNT.......................$"+total);
}
}