Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. //Robert Corrato
  2. //9/9/19 APCSA
  3. public class TipCalc{
  4. public static void main(String[] args) {
  5.  
  6. int twentyPercent; // must be interger (whole number)
  7. double bill;
  8. double tip;
  9. double subtotal;
  10. int tries;
  11.  
  12. Scanner sc = new Scanner(System.in);
  13. //$ shows up
  14. //Looked this up, thought it would be cool.
  15. System.out.println("What is the value of your bill?");
  16. bill = sc.nextDouble();
  17.  
  18. System.out.println("You are going to tip 20%. Don't be stingy."); // Enter tip percentage
  19. twentyPercent = sc.nextInt();
  20.  
  21.  
  22. tip = (bill + tip) / 100; //the tip
  23. subtotal = bill + tip; // This calculates your total
  24.  
  25. System.out.println("Tip Amount " + fmt1.format(tip));
  26. System.out.println("Total including Tip " + fmt1.format(subtotal));
  27.  
  28. System.out.println("Would you like to split the tip? Yes or no?");
  29. String answer = sc.nextLine();
  30. if (answer == "yes"){
  31. System.out.println("How many people will you split the tip with?");
  32. int split = sc.nextInt();
  33. System.out.println("The new total for each person will be " + subtotal/split);
  34. }else{
  35. System.out.println("Wow, you are a nice person, or a very lonely person.");
  36.  
  37. System.out.println("Would you like to calculate another tip? 1 for yes");
  38. int playAgain = sc.nextInt();
  39. if (playAgain != 1){
  40. playAgain = true;
  41. }else{
  42.  
  43. tries = 0;
  44.  
  45. }
  46.  
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement