Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. /**
  2. * Write a description of class TipCalulator here.
  3. *
  4. * @Arjun Bhamra
  5. * @9/6/19
  6. */
  7.  
  8. import java.util.Scanner;
  9. public class TipCalulator
  10. {
  11. public static void main(String[] args){
  12. TipCalculate();
  13. Scanner qp = new Scanner(System.in);
  14. System.out.println("Press 1 to use again or 2 to exit.");
  15. int choice=qp.nextInt();
  16. if(choice==1){
  17. TipCalculate();
  18. } else if(choice==2){
  19. System.out.println("Thank you for shopping with us!");
  20. }
  21. }
  22. public static void TipCalculate(){
  23. Scanner sc = new Scanner(System.in);
  24. System.out.println("What is the cost of the bill? Keep to two significant figures!");
  25. double cost = sc.nextDouble();
  26.  
  27. Scanner kb = new Scanner(System.in);
  28. System.out.println("What percentage of the bill would you like to tip?");
  29. double percentage = kb.nextDouble();
  30.  
  31. double tip = ((percentage/100)*cost);
  32. double totalCost = (cost+tip);
  33.  
  34. System.out.println("By choosing to tip "+percentage+ "%, you are tipping $" + tip);
  35. System.out.println("Your total cost for this meal is $" + totalCost);
  36.  
  37. Scanner ab = new Scanner(System.in);
  38. System.out.println("How many people will be splitting the bill?");
  39. int people = ab.nextInt();
  40.  
  41. double split = (totalCost/people);
  42. System.out.println("Each person will have to pay $" + split);
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement