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 22:00
What is a distinguishing feature of today’s graphic application software?) graphic applications are used today on a variety of devices, including touch-screen kiosks and mobile phones.
Answers: 3
question
Computers and Technology, 23.06.2019 06:30
How do you write an argumentative essay about the importance of free enterprise ?
Answers: 1
question
Computers and Technology, 24.06.2019 06:50
What are the things you are considering before uploading photos on social media?
Answers: 1
question
Computers and Technology, 25.06.2019 05:10
What is the disadvantage of a mesh topology?
Answers: 1
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, 08.12.2020 21:30
question
Mathematics, 08.12.2020 21:30
question
Biology, 08.12.2020 21:30
question
History, 08.12.2020 21:30
Questions on the website: 13722361