Answered step by step
Verified Expert Solution
Question
1 Approved Answer
After a hard quarter in the office you decide to get some rest on a vacation. So you will book a flight for you
After a hard quarter in the office you decide to get some rest on a vacation. So you will book a flight for you and your girlfriend and try to leave all the mess behind you. You will need a rental car in order for you to get around in your vacation. The manager of the car rental makes you some good offers: Every day you rent the car costs $40. If you rent the car for 7 or more days, you get $50 off your total. Alternatively, if you rent the car for 3 or more days, you get $20 off your total. Write a method public static int costForDuration(int d) which gives you the rental cost for a rental duration of d days. Then build a main method to call the costForDuration method in a loop to find out your rental cost for 1 to 10 days. Sample output: (Your output should be identical) For 1 days, your cost is $40. For 2 days, your cost is $80. For 3 days, your cost is $100. For 4 days, your cost is $140. For 5 days, your cost is $180. For 6 days, your cost is $220. For 7 days, your cost is $230. For 8 days, your cost is $270. For 9 days, your cost is $310. For 10 days, your cost is $350.
Step by Step Solution
★★★★★
3.50 Rating (150 Votes )
There are 3 Steps involved in it
Step: 1
This code defines two methods costForDurationint d This method takes th...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started