Create a class named CarRental that contains field\'s for: renter\'s name, zip c
ID: 3764146 • Letter: C
Question
Create a class named CarRental that contains field's for:
renter's name, zip code,size of car, daily rental fee, length of rental (in days), and total rental fee.
The class should include a constructor that requires all the rental data except the daily rate and total fee, which are calculated based on the size of the car:
economy size ($ 29.99 per day), midsize ($ 38.99), and full size ($ 43.50).
The class also includes a display() method that will display all the rental information.
Create a subclass name LuxuryCarRental. This class sets the rental fee at $79.99 per day and prompts the user to respond to the option of including a chauffeur at an addition $200 per day. Override the parent class display() method to include chauffeur 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.
Explanation / Answer
import java.util.Scanner;
public class RentalCar
{
public RentalCar(String zIP, String name, String model,
char classification, double rental, int mileNum)
{
}
public RentalCar() {
}
public static void main(String[] args){
Scanner input = new Scanner (System.in);
String ZIP;
String Name;
String Model;
char Classification;
double Rental;
int MileNum;
System.out.print("Enter the ZIP number: ");
ZIP = input.next();
System.out.print("Enter Renter name: ");
Name = input.next();
System.out.print("Enter Model: ");
Model = input.next();
System.out.print("Enter Classification; ");
Classification = input.next().charAt(0);
System.out.print("Enter Rental: ");
Rental = input.nextDouble();
System.out.print("Enter Miles: ");
MileNum = input.nextInt();
System.out.println();
RentalCar rentalCar1 = new RentalCar(ZIP, Name, Model, Classification, Rental, MileNum);
RentalCar rentalCar2 = new RentalCar();
rentalCar1.print();
rentalCar1.setmiles(75);
System.out.println();
System.out.println("The number of miles of the car is: " + rentalCar1.getmiles());
System.exit(0);
}
private String getmiles() {
return null;
}
private void setmiles(int i) {
}
private void print() {
}
class TestRentalCar {
private
String ZIP;
String Name;
String Model;
char Classification;
double Rental;
int MileNum;
public void
RentalCar(){}
void RentalCar(String vin, String name, String model, char classification, double rental, int milenum) {
ZIP = zip;
Name = name;
Model = model;
Classification = classification;
Rental = rental;
MileNum = milenum;
}
public void print() {
System.out.println("ZIPof the car is: " + ZIP);
System.out.println("Name of the car is: " + Name);
System.out.println("Model of the car is: " + Model);
System.out.println("Classification of the car is " + Classification);
System.out.println("Miles of the car is: " + MileNum);
}
public void setmiles(int milenum) {
MileNum = milenum;
}
public int getmiles() {
return MileNum;
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.