Question: Write a method dateNight that takes an argument representing the amount of money in dollars in your pocket. You are treating someone to a date

Write a method dateNight that takes an argument representing the amount of money in dollars in your pocket. You are treating someone to a date at a restaurant. Entrees are $20 apiece, appetizers are $10, and desserts are $7.50. You want to buy two entrees, an appetizer, and a dessert. You won't buy anything and will leave the restaurant if you can't afford the two entrees. Otherwise, you will buy them. If you can also afford an appetizer, you will buy that, and if you can afford a dessert at that point, you will buy that (whether or not you could afford the appetizer). Return a number equal to how much money you will have remaining after following the above plan (assume no tax, tip, or other fees).
This is what I have but in the main string the system says test 48 fails
public static double dateNight(double amount){
if(amount <2*20){
return amount;
}
else {
amount = amount -2*20;
if (amount <10){
return amount;
}
else {
amount = amount -10;
if (amount <7.50){
return amount;
}
else {
amount = amount -7.50;
return amount;
}
}
}
}
what I amnot writing correctly?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!