Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Tiprate
- {
- public static void main(String[] args)
- {
- //declare variables
- double subtotal, taxRate, tipFifteen, tipEighteen, tipTwenty, tip, tax, total;
- //set intinal values
- subtotal = 30;
- taxRate = 0.095;
- tipFifteen = 0.15;
- tipEighteen = 0.18;
- tipTwenty = 0.2;
- //15% tip
- System.out.println("\nBill with 15% tip");
- System.out.print("\n");
- System.out.println("---------------------");
- System.out.print("\n");
- System.out.println("Subtotal: $" + subtotal);
- tip = subtotal * tipFifteen;
- System.out.println("Tip: $" + tip);
- tax = (subtotal + tip) * taxRate;
- System.out.println("Tax: $" + tax);
- total = subtotal + tip + tax;
- System.out.println("Total Bill : $" + total);
- //18% tip
- System.out.println("\n\nBill with 18% tip");
- System.out.print("\n");
- System.out.println("---------------------");
- System.out.print("\n");
- System.out.println("Subtotal: $" + subtotal);
- tip = subtotal * tipEighteen;
- System.out.println("Tip: $" + tip);
- tax = (subtotal + tip) * taxRate;
- System.out.println("Tax: $" + tax);
- total = subtotal + tip + tax;
- System.out.println("Total Bill : $" + total);
- //20% tip
- System.out.println("\n\nBill with 20% tip");
- System.out.print("\n");
- System.out.println("---------------------");
- System.out.print("\n");
- System.out.println("Subtotal: $" + subtotal);
- tip = subtotal * tipTwenty;
- System.out.println("Tip: $" + tip);
- tax = (subtotal + tip) * taxRate;
- System.out.println("Tax: $" + tax);
- total = subtotal + tip + tax;
- System.out.println("Total Bill : $" + total);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement