Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ch4ex11;
- import java.util.Scanner;
- public class Ch4Ex11
- {
- public static void main(String[] args)
- {
- Scanner sc=new Scanner(System.in);
- System.out.print("Enter the number of burgers: ");
- int burgers=sc.nextInt();
- System.out.print("Enter the number of fries: ");
- int fries=sc.nextInt();
- System.out.print("Enter the number of sodas: ");
- int sodas=sc.nextInt();
- double total=(burgers*1.69)+(fries*1.09)+(sodas*0.99);
- System.out.printf("Total before tax: $%.2f",total);
- double tax=total*0.065;
- System.out.printf("\nTax: $%.2f",tax);
- System.out.printf("\nFinal total: $%.2f",(total+tax));
- System.out.print("\nEnter amount tendered: $");
- double money=sc.nextDouble();
- while(money<(total+tax))
- {
- System.out.print("Insufficient funds! Enter new ammount: $");
- money=sc.nextDouble();
- }
- double change=money-(total+tax);
- System.out.printf("Change: $%.2f",change);
- System.out.println("");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement