subject

Create a class named CarRental that contains fields that hold a renter's name, zip code, size of the car rented, daily rental fee, length of rental in days, and total rental fee. The class contains a constructor that requires all the rental data except the daily rate and total fee, which are calculated bades on the sice of the car; economy at $29.99 per day, midsize at 38.99$ per day, or full size at 43.50 per day. The class also includes a display() method that displays all the rental data. Create a subclass named LuxuryCarRental. This class sets the rental fee at $79.99 per day and prompts the user to respond to the option of including a chauffer at $200 more per day. Override the parent class display() method to include chauffer fee information. Write an application named UseCarRental that prompts the user for the data needed for a rental and creates an object of the correct type. Display the total rental fee. Save the files as CarRental. java, LuxaryCarRental. java, and UseCarRental. java. Here is my code:

package CarRental;
public class CarRental
{
String name;
int zipcode;
String size;
double dFee;
int days;
double total;

public String getName()
{
return name;
}
public int getZipcode()
{
return zipcode;
}
public String getSize()
{
return size;
}
public int getDays()
{
return days;
}
public CarRental(String size)
{
if(size. charAt(0)=='m')
dFee = 38.99;
else
if(size. charAt(0)=='f')
dFee = 43.50;
else
dFee = 29.99;
}
public void calculateTotal(int days)
{
total = dFee*days;
}
public void print()
{
System. out. println("Your rental total cost is: $" + total);
}

}

package CarRental;
import java. util.*;
public class LuxaryCarRental extends CarRental
{
public LuxaryCarRental(String size, int days)
{
super(size);
}
public void CalculateTotalN()
{
super. calculateTotal(days);
dFee = 79.99;

int chauffer;
Scanner keyboard = new Scanner(System. in);
System. out. println("Do you want to add a chauffer for $200? Enter 0 for"
+ " yes and 1 for no");
chauffer = keyboard. nextInt();

if(chauffer!=1)
total = dFee;
else
total = dFee + 100;
}
}

package CarRental;
import java. util.*;
public class UseCarRental
{
public static void main(String args[])
{
String name, size;
int zipcode, days;

Scanner keyboard = new Scanner(System. in);

System. out. println("Enter total days you plan on renting: ");
days = keyboard. nextInt();

System. out. println("Enter your name: ");
name = keyboard. next();

System. out. println("Enter your billing zipcode: ");
zipcode = keyboard. nextInt();

System. out. println("Enter the size of the car: ");
size = keyboard. next();

CarRental economy = new CarRental(size);
economy. calculateTotal(days);
economy. print();

LuxaryCarRental fullsize = new LuxaryCarRental(size, days);
fullsize. CalculateTotalN();
fullsize. print();

}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 14:30
Hi plz 11 ! when planning a table, what step comes first: "define the column headers" or "calculate the number of columns/rows"? a. calculate the number of columns/rows b. define the column headers
Answers: 1
question
Computers and Technology, 22.06.2019 23:30
What does 21 pilots middle aged name as a band 15 years prior to them naming their band 21 pilots?
Answers: 1
question
Computers and Technology, 23.06.2019 15:00
1. which of the following statements are true about routers and routing on the internet. choose two answers. a. protocols ensure that a single path between two computers is established before sending packets over it. b. routers are hierarchical and the "root" router is responsible for communicating to sub-routers the best paths for them to route internet traffic. c. a packet traveling between two computers on the internet may be rerouted many times along the way or even lost or "dropped". d. routers act independently and route packets as they see fit.
Answers: 2
question
Computers and Technology, 24.06.2019 04:30
Which of the following terms refers to a collection of different types of software that share the goal of infiltrating a computer and making it do something? a- malware b- virus c- spyware d- trojan horse
Answers: 2
You know the right answer?
Create a class named CarRental that contains fields that hold a renter's name, zip code, size of the...
Questions
question
Mathematics, 13.12.2019 15:31
Questions on the website: 13722367