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 01:00
What is added to the < meta > tag to describe the encoding type?
Answers: 2
question
Computers and Technology, 22.06.2019 15:30
Melissa needs to add a topic to an email that she will send to her teacher. choose the name of the field where she should type her topic.
Answers: 2
question
Computers and Technology, 23.06.2019 04:40
The narrative structure of the popular movies can be broken down into
Answers: 3
question
Computers and Technology, 23.06.2019 06:00
What makes myhexadecimalnumber a child of mynumber? which methods does myhexadecimalnumber inherit directly from the mynumber class? what can an instance of the mynumber class do? what can an instance of the myhexadecimalnumber class do? which methods are overridden? why are they overridden? how many examples of overloading are there? why was this done? where is the super keyword used? what is it doing? why isn’t the incoming value set immediately in the second myhexadecimalnumber constructor? how many examples can you find of an inherited method being called?
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, 28.05.2020 03:01
question
Social Studies, 28.05.2020 03:01
question
Social Studies, 28.05.2020 03:01
Questions on the website: 13722365