Advertisement
KeeganT

Ch4Ex11

Feb 6th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. package ch4ex11;
  2. import java.util.Scanner;
  3.  
  4. public class Ch4Ex11
  5. {
  6.     public static void main(String[] args)
  7.     {
  8.         Scanner sc=new Scanner(System.in);
  9.         System.out.print("Enter the number of burgers: ");
  10.         int burgers=sc.nextInt();
  11.         System.out.print("Enter the number of fries: ");
  12.         int fries=sc.nextInt();
  13.         System.out.print("Enter the number of sodas: ");
  14.         int sodas=sc.nextInt();
  15.         double total=(burgers*1.69)+(fries*1.09)+(sodas*0.99);
  16.         System.out.printf("Total before tax: $%.2f",total);
  17.         double tax=total*0.065;
  18.         System.out.printf("\nTax: $%.2f",tax);
  19.         System.out.printf("\nFinal total: $%.2f",(total+tax));
  20.         System.out.print("\nEnter amount tendered: $");
  21.         double money=sc.nextDouble();
  22.         while(money<(total+tax))
  23.         {
  24.             System.out.print("Insufficient funds! Enter new ammount: $");
  25.             money=sc.nextDouble();
  26.         }
  27.         double change=money-(total+tax);
  28.         System.out.printf("Change: $%.2f",change);
  29.         System.out.println("");
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement