Question
2. Sammy's Seashore Supplies rents beach equipment to tourists. In previous chapters, you developed a class that holds equipment rental information and an application that
2. Sammy's Seashore Supplies rents beach equipment to tourists. In previous chapters, you developed a class that holds equipment rental information and an application that tests the methods using four objects of the class. Now modify the RentalDemo class to do the following:
-Continously prompt for the number of minutes of each Rental until the value falls between 60 and 7,200 inclusive.
-For one of the Rental objects, create a loop that displays "Coupon good for 10 percent off next rental" as many times as there are full hours in the Rental.
Save the modified file as Rental Demo.java
Java Programming 8th Edition
*** Here is the Rental.java class ***
class Rental
{
public static final int MINUTES_IN_HOURS = 60;
public static final double HOUR_RATE = 40.00;
private String contractNumber;
private int hours;
private int extraMinutes;
private double price;
public Rental(String num, int minutes)
{
setContractNumber(num);
setHoursAndMinutes(minutes);
}
public Rental()
{
this("A000", 0);
}
public void setContractNumber(String num)
{
contractNumber = num;
}
public void setHoursAndMinutes(int minutes)
{
hours = minutes / MINUTES_IN_HOUR;
extraMinutes = minutes % MINUTES_IN_HOUR;
if(extraMinutes <= HOUR_RATE)
price = hours * HOUR_RATE + extraMinutes;
else
price = hours * HOUR_RATE + HOUR_RATE;
}
public String getContractNumber()
{
return contractNumber;
}
public int getHours()
{
return hours;
}
public int getExtraMinutes()
{
return extraMinutes;
}
public double getPrice()
{
return price;
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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