Skip to content

Commit 2bbc7ed

Browse files
Restaurant Bill
1 parent 8322d17 commit 2bbc7ed

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
Write a program that computes the tax and tip on a restaurant bill.
3+
The program should ask the user to enter the charge for the meal.
4+
The tax should be 6.75 percent of the meal charge.
5+
The tip should be 20 percent of the total after adding the tax.
6+
Display the meal charge, tax amount, tip amount, and total bill on the screen.
7+
*/
8+
9+
package com.challenges;
10+
11+
import java.util.Scanner;
12+
13+
public class RestaurantBill {
14+
public static void main(String [] main) {
15+
16+
// Declare Variable
17+
double mealCharge;
18+
final double TAX_PERCENTAGE = 0.0675;
19+
final double TIP_PERCENTAGE = 0.20;
20+
double totalTax;
21+
double totalTip;
22+
double totalBill;
23+
24+
Scanner scanner = new Scanner(System.in);
25+
26+
System.out.println("Please enter the cost of the meal: ");
27+
mealCharge = scanner.nextDouble();
28+
29+
totalTax = mealCharge * TAX_PERCENTAGE;
30+
totalTip = (mealCharge + totalTax) * TIP_PERCENTAGE;
31+
totalBill = mealCharge + totalTax + totalTip;
32+
33+
System.out.println("Charge for the meal: $" + mealCharge);
34+
System.out.println("Total Tax on the meal: $" + totalTax);
35+
System.out.println("Total Tip on the meal: $" + totalTip);
36+
System.out.println("Total Bill: $" + totalBill);
37+
}
38+
}

0 commit comments

Comments
 (0)