Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. /*Maya Gambhir
  2. * B block AP CS A
  3. * Tip Calculator program
  4. */
  5. import java.util.*;
  6.  
  7. public class TipCalculator
  8. {
  9. public static void main (String[]args) {
  10. Scanner sc=new Scanner(System.in);
  11. int again=1;
  12. while (again==1){
  13. System.out.println("How much is your bill? ");
  14. double bill=sc.nextDouble();
  15.  
  16. System.out.println("\nWhat percent would you like to tip? ");
  17. int percent=sc.nextInt();
  18.  
  19. //calculate tip
  20. double tip=(((double)percent)/100)*bill;
  21. double totalBill=bill+tip;
  22. System.out.println("\nTotal tip is $"+tip);
  23. System.out.println("\nTotal bill is $"+totalBill);
  24.  
  25. //split
  26. System.out.println("\nHow many people would you like to split \nthe bill with?");
  27. int split=sc.nextInt();
  28. double splitBill=totalBill/split;
  29.  
  30. System.out.println("\nEach person pays $"+splitBill);
  31.  
  32. //again?
  33. System.out.println("\nPress 1 to calculate another tip");
  34. System.out.println("Press 2 to quit");
  35. again=sc.nextInt();
  36.  
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement