Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The language is java The rental rates are: Season Months Charge Spring March, Ap

ID: 3911272 • Letter: T

Question

The language is java

The rental rates are:

Season

Months

Charge

Spring

March, April, May

$200.00

Summer

June, July, August

$300.00

Fall

September, October, November

$250.00

Winter

December, January, February

$100.00

You will need to use the following classes for your program:

VacationHomeRental class

Keeps track of the information about a vacation home rental and handles calculations for the rental. It should include the following:

Constants

15 percent discount (used if the vacation home is rented for more than 7 days)

$250 returnable deposit

prices for the different seasons (see rental rates above)

Instance variables

number of days the vacation home is rented

number of vacation homes rented

rental date, entered and stored in the format mm/dd/yyyy

Methods

constructor accepting values for all instance variables

calculateTotal – calculates the total cost for the rental. This is calculated by the cost of the rental(s) minus the discount amount plus the deposit.

calculateVacationHomeCost – calculates the cost of the vacation home based on the number of days, number of vacation homes rented, and the season. --

calculateDiscount – calculates the discount --

calculateDeposit – determines the deposit required based on $250 per vacation home rented. --

determinePrice – determines the price for each rental based on month --

determineDiscount – determines whether there should be a discount (rental for greater than 7 days). It returns the discount percent or zero if no discount should be given. --

Getters and setters for all instance variables

Customer class

Keeps track of the customer name, mailing address, and phone information.

Instance Variables

Variables for first and last names, street address, city, state, zip code, and phone.

Methods

constructor with no arguments

constructor receiving all instance variables

formatLabel method that formats the customer or resort information. This should be placed in a String to be returned from the method. See the format in the Sample Run.

formatPhone method - The phone should be entered in the form xxxxxxxxxx and formatted for display to the form     (xxx)xxx-xxxx

Getters and setters for all instance variables.

You will use this class to create objects for both the resort and the customer.   When an object is created for the resort, the name should be placed in the last name. You will need to add logic in formatLabel method to determine whether it is formatting for the resort or customer. For a resort object, the firstName will be null.

VacationHomeInput class

Handles all of the input from the user.

Methods

readRentalOrder – this method should prompt and read all of the information for a rental. It should create and return a rental object. Use the prompts illustrated in the sample run.

readCustomer – this method should read all of the information for a customer. It should create and return a customer object.

VacationHomeOutput class

Handles all output except prompts which are in the input class.

Methods (Use Sample Run for specifics)

displayGreeting – welcome to the customer.

displayReceipt – displays the cost of rental, discount (only display if the customer gets a discount), deposit, and total.

displayCustomer – displays the customer information as formatted in the formatLabel method.

displayGoodbye – thank you and resort information formatted using the formatLabel method.

VacationHomeDriver class

The driver is the class with the main method. It should first greet the customer. Then it should call readRentalOrder and readCustomer to get the required information.   Output should display the customer information, the receipt, and a polite goodbye.

You will need two instances of the Customer object. One for the resort – create the object and hard code the information stored in the object in the driver. The second one will be created when info about the customer is read from the user.

Season

Months

Charge

Spring

March, April, May

$200.00

Summer

June, July, August

$300.00

Fall

September, October, November

$250.00

Winter

December, January, February

$100.00

Explanation / Answer

import java.util.*;

class VacationHomeRental

{

static final springchg=200;

static final summerchg=300;

static final fallchg=250;

static final winterchg=100;

static final bankdiscount=15;

static final returnableamount=250;

int days,homes;

Date date;

VacationHomeRental(int days,int homes,String date)

{

this.days=days;

this.homes=homes;

this.date=new Date(date);

}

public int calculateTotal()

{

return calculateVacationHomeCost()-calculateDiscount()+calculateDeposit();

}

public int calculateVacationHomeCost()

{

int cost=0

int n=days/30;

String months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",

"Sep", "Oct", "Nov", "Dec" };

GregorianCalendar cal=new GregorianCalendar();

cal.setTime(date);

while(n-->0)

cost+=determinePrice(months[cal.get(Calendar.MONTH)])

return homes*cost;

}

public int calculatediscount()

{

return determinediscount();

}

public int determinePrice(String mon)

{

if(mon=="mar" || mon=="Apr" || mon=="May")

return springchg;

else if(mon=="Jun" || mon="Jul" || mon=="Aug")

return summerchg;

else if(mon=="Sep" || mon=="Oct" || mon=="Nov")

return fallchg;

else if(mon=="Jan" || mon=="Feb" || mon=="Feb")

return winterchg;

}

public int determinediscount()

{

if(days/7<=1)

return 0;

else

return bankdiscount*calculateVacationHomeCost();

}

public int calculateDeposit()

{

return returnableamount;

}

}

class Customer

{

String name,malingAddress,Phoneinfo;

Customer()

{}

public void setName(String name)

{

this.name=name;

}

public void setMailingAddress(String malingAddress)

{

this.mailingAddress=mailingAddress;

}

public void setphoneinfo(String phoneinfo)

{

this.phoneinfo=phoneinfo;

}

public String getName()

{

return name;

}

public String getMailingAddress()

{

return mailingAddress;

}

public String getphoneinfo()

{

return phoneinfo;

}

}

class VacationHomeInput

{

Scanner sc=new Scanner(System.in);

public VacationHomeRental readRentalOrder()

{

new VacationHomeRental(sc.nextInt(),sc.nextInt(),sc.next());

}

public Customer readCustomer()

{

Customer c=new Customer();

c.setName(sc.next());

c.setMailingAddress(sc.next());

c.setphoneinfo(sc.next());

}

}

class VacationHomeOutput

{

VacationHomeInput vc=new VacationHomeInput();

public void displayGreeting()

{

System.out.println("Welcome to our home");

}

public void displayReciept()

{

VacationHomeRental vcr=vc.readRentalOrder();

System.out.println(vcr.calculateVacationHomeCost());

System.out.println(vcr.calculatediscount());

System.out.println(vcr.calculateTotal());

}

public void displayCustomer()

{

Customer c=vc.readCustomer();

System.out.println(c.getName());

System.out.println(c.getMailingAddress());

System.out.println(c.getphoneinfo());

}

}

class VacationHomeDriver

{

public static void main()

{

VacationHomeOutput vo=new VacationHomeOutput();

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote