Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Write a method called calculateTotalPayment that takes two
- // arguments, an int meal which is the cost of a meal, and a
- // double tip which represents the tip percentage one would add to
- // the bill.
- // The method must return a double which equals how much should be
- // paid.
- //
- // int meal must be greater than 0
- // double tip must be 0 or greater and .7 or less (no tips over 70%)
- // If either number is invalid, return -1;
- //
- // Don't forget to use the public static modifiers
- public static double calculateTotalPayment(int x, double tip){
- double total;
- total = 0;
- if((x > 0) && (tip < 0.7) && (tip >= 0)) {
- total = x + (tip * total);
- }
- else {
- total = -1;
- }
- return total;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement