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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 21:00, mazolethrin9632
Which of these is most responsible for differences between the twentieth century to the twenty-first century?
Answers: 2
image
Computers and Technology, 23.06.2019 02:00, vivian2020
Read this excerpt from helen keller’s autobiography, the story of my life. have you ever been at sea in a dense fog, when it seemed as if a tangible white darkness shut you in, and the great ship, tense and anxious, groped her way toward the shore with plummet and sounding-line, and you waited with beating heart for something to happen? i was like that ship before my education began, only i was without compass or sounding-line, and had no way of knowing how near the harbour was. "light! give me light! " was the wordless cry of my soul, and the light of love shone on me in that very hour. . the morning after my teacher came she led me into her room and gave me a doll. the little blind children at the perkins institution had sent it and laura bridgman had dressed it; but i did not know this until afterward. when i had played with it a little while, miss sullivan slowly spelled into my hand the word "d-o-l-l." i was at once interested in this finger play and tried to imitate it. when i finally succeeded in making the letters correctly i was flushed with childish pleasure and pride. running downstairs to my mother i held up my hand and made the letters for doll. i did not know that i was spelling a word or even that words existed; i was simply making my fingers go in monkey-like imitation. in the days that followed i learned to spell in this uncomprehending way a great many words, among them pin, hat, cup and a few verbs like sit, stand and walk. based on this excerpt, which words best describe helen keller?
Answers: 2
image
Computers and Technology, 24.06.2019 05:30, roderickhinton
Someone plzz me which of these defines a social search? a. asking a search engine a question that is answered by a real person on the other sideb. modifying search results based on popularity of a web pagec. modifying search results based on a ranking of a web page
Answers: 2
image
Computers and Technology, 24.06.2019 08:20, bob4059
Evaluate the scenario below and indicate how to handle the matter appropriately. situation: michael received an e-mail from what he thought was his doctor’s office, requesting his social security number. since he had just been in to see his doctor last week, he replied to the e-mail with his social security number.
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 in other subjects:

Konu
Mathematics, 06.09.2019 08:20