Advertisement
parkerlreed

Untitled

Sep 17th, 2012
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.68 KB | None | 0 0
  1. public class Tiprate
  2. {
  3.     public static void main(String[] args)
  4.     {
  5.         //declare variables
  6.         double subtotal, taxRate, tipFifteen, tipEighteen, tipTwenty, tip, tax, total;
  7.        
  8.         //set intinal values
  9.         subtotal = 30;
  10.         taxRate = 0.095;
  11.         tipFifteen = 0.15;
  12.         tipEighteen = 0.18;
  13.         tipTwenty = 0.2;
  14.        
  15.         //15% tip
  16.         System.out.println("\nBill with 15% tip");
  17.         System.out.print("\n");
  18.         System.out.println("---------------------");
  19.         System.out.print("\n");
  20.         System.out.println("Subtotal: $" + subtotal);
  21.        
  22.         tip = subtotal * tipFifteen;
  23.        
  24.         System.out.println("Tip: $" + tip);
  25.        
  26.         tax = (subtotal + tip) * taxRate;
  27.        
  28.         System.out.println("Tax: $" + tax);
  29.        
  30.         total = subtotal + tip + tax;
  31.        
  32.         System.out.println("Total Bill : $" + total);
  33.        
  34.         //18% tip
  35.         System.out.println("\n\nBill with 18% tip");
  36.         System.out.print("\n");
  37.         System.out.println("---------------------");
  38.         System.out.print("\n");
  39.         System.out.println("Subtotal: $" + subtotal);
  40.        
  41.         tip = subtotal * tipEighteen;
  42.        
  43.         System.out.println("Tip: $" + tip);
  44.        
  45.         tax = (subtotal + tip) * taxRate;
  46.        
  47.         System.out.println("Tax: $" + tax);
  48.        
  49.         total = subtotal + tip + tax;
  50.        
  51.         System.out.println("Total Bill : $" + total);
  52.        
  53.         //20% tip
  54.         System.out.println("\n\nBill with 20% tip");
  55.         System.out.print("\n");
  56.         System.out.println("---------------------");
  57.         System.out.print("\n");
  58.         System.out.println("Subtotal: $" + subtotal);
  59.        
  60.         tip = subtotal * tipTwenty;
  61.        
  62.         System.out.println("Tip: $" + tip);
  63.        
  64.         tax = (subtotal + tip) * taxRate;
  65.        
  66.         System.out.println("Tax: $" + tax);
  67.        
  68.         total = subtotal + tip + tax;
  69.        
  70.         System.out.println("Total Bill : $" + total);
  71.        
  72.     }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement