Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class TipCalculator {
  4.  
  5. public static void main(String[] args) {
  6. Scanner sc = new Scanner(System.in);
  7. String calc = "yes";
  8.  
  9. while (calc.equals ("yes")) {
  10. System.out.println("Enter Total Amount of Bill");
  11. Double tot = (double) sc.nextDouble();
  12.  
  13. System.out.println("Enter percent you would like to tip");
  14. Double per = (sc.nextDouble() * .01);
  15.  
  16. double tip = (per * tot);
  17.  
  18. System.out.println("Amount of Tip:" + tip);
  19. System.out.println("Total Bill:" + (tip + tot));
  20.  
  21. System.out.println("How many people are splitting the bill?");
  22. int ppl = sc.nextInt();
  23. double splt = ((tip + tot) / ppl);
  24. System.out.println("Each persons total is: $" + splt);
  25.  
  26. sc.nextLine();
  27. System.out.println("Would you like to run again?");
  28. calc = sc.nextLine();
  29.  
  30. }
  31.  
  32. }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement