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

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!