Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. // Write a method called calculateTotalPayment that takes two
  2. // arguments, an int meal which is the cost of a meal, and a
  3. // double tip which represents the tip percentage one would add to
  4. // the bill.
  5. // The method must return a double which equals how much should be
  6. // paid.
  7. //
  8. // int meal must be greater than 0
  9. // double tip must be 0 or greater and .7 or less (no tips over 70%)
  10. // If either number is invalid, return -1;
  11. //
  12. // Don't forget to use the public static modifiers
  13.  
  14.  
  15.  
  16. public static double calculateTotalPayment(int x, double tip){
  17. double total;
  18. total = 0;
  19. if((x > 0) && (tip < 0.7) && (tip >= 0)) {
  20. total = x + (tip * total);
  21. }
  22. else {
  23. total = -1;
  24. }
  25. return total;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement