Question
complete the code import java.text.NumberFormat; public class Rental { // the Rental class has four fields private Customer cust; private Auto auto; private int numDays;
complete the code
import java.text.NumberFormat;
public class Rental {
// the Rental class has four fields
private Customer cust;
private Auto auto;
private int numDays;
private double rentalCost;
private char discount; // N = none G = gold D = days B = both
// all cars rent for $15.00 per day
final private double COST_PER_DAY = 15.00;
// TO DO!!write an empty and a full constructor
// toString method
//remember that each class should print out its own fields
// so we let the Auto and Customer class print out theirs
// this class only prints out the number of days field
@Override
public String toString()
{
NumberFormat nf = NumberFormat.getCurrencyInstance();
String string;
string = cust.toString() + " rented " ;
string = string + auto.toString() + " for " + numDays + " days.";
string = string + " The cost was " + nf.format(rentalCost) + " ";
switch (discount) {
case 'B':
string = string + "This person was both a gold card memeber and rented over six days and received a a 25% discount";
break;
case 'G':
string = string + "This person was a gold card memeber and received a a 10% discount";
break;
case 'D':
string = string + "This person rented over six days and received a 15% discount";
break;
case 'N':
string = string + "This person did not qualify for a discount";
}
return string;
}
// TO DO!!!the setRentalCost is where the cost is set
public void setRentalCost()
{
// give them a 15% discount if they rent over 6 days. Also Gold card members get an
//extra 10% off the original cost regardless of the number of days
// note next line is just a place holder. Also set the discount code
}
// generate getters and setters
}
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