Computers and Technology
Computers and Technology, 04.08.2020 22:01, ayeeeee98

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();

}

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 14:30, camerondillonn
If the polar bear were taken out of the food chain what would happen to the seal population the seal population would diminish the seal population would grow dramatically the seal population would stay the same the seal population would decrease slightly
Answers: 1
image
Computers and Technology, 22.06.2019 18:00, deathfire5866
Determine whether the following careers would require training or college.
Answers: 1
image
Computers and Technology, 24.06.2019 01:00, kayranicole1
What shows the web address of the page that is currently displayed in the workspace? status window toolbar location bar internet box
Answers: 1
image
Computers and Technology, 24.06.2019 08:10, anthonysutton82
Where are american poets found in the dewey decimal system
Answers: 1
Do you know the correct answer?
Create a class named CarRental that contains fields that hold a renter's name, zip code, size of the...

Questions in other subjects:

Konu
Mathematics, 20.06.2020 02:57