Develop car rental application may use to produce a receipt. A receipt will be f
ID: 3790176 • Letter: D
Question
Develop car rental application may use to produce a receipt. A receipt will be format follows: Rental Receipt Customer John Jones Driver License PA 12343 Telephone 724 555-8345 Credit Card VISA 12345678012 Mercedes 350E Tag PA 342399 Rent Class Luxury Sedan Daily Rate 95.00 Weekly Rate 545.00 Date/Time out 01/10/2017 at 10:45 Date/Time In 01/20/2017 at 11:44 Rental charge 830.00 Airport Tax 150.00 Sales Tax 49.80 Total 1029.80 For this application create four main classes for customer, rental class, vehicle, and rental agreement. The customer class should have six pieces of information (i.e. instance variables including customer name (as a String), driver's license state (as a String), driver's license number (as an int), telephone number (as a String), credit card type (as a String), and credit card number (as a long). A rental class represents the rental terms for a class of vehicle. For example Compact, Mid-Size, Full Size, Sport etc. are classifications of cars with each time having different rental terms. A rental class should have three pieces of information: a rental class name (as a String), a daily rate (as a double) and a weekly rate (as a double). A vehicle should have four pieces of information: a make/model (as a String), state issuing a tag (as a String), a tag number (as a String) and a rental class (as a rental class). Lastly a rental agreement is the agreement of a customer to rental a given vehicle together with the rental terms, date/time out and date time in. Thus a rental agreement has 4 pieces of information: the customer, the vehicle, date/time out (as a LocalDateTime) and date/time in For your customer class, provide a constructor accepting values for all instance variables. Provide getter methods for all instance variables, but setter methods for only the telephone, credit card type and credit card number variables.Explanation / Answer
public class Customer {
private String customerName;
private String driverLicenceDate;
private int driverLicenceNo;
private String telephoneNo;
private String creditCartType;
private long creditCardNo;
public Customer(String customerName, String driverLicenceDate,
int driverLicenceNo, String telephoneNo, String creditCartType,
long creditCardNo) {
this.customerName = customerName;
this.driverLicenceDate = driverLicenceDate;
this.driverLicenceNo = driverLicenceNo;
this.telephoneNo = telephoneNo;
this.creditCartType = creditCartType;
this.creditCardNo = creditCardNo;
}
public Customer(String customerName, int driverLicenceNo,
String telephoneNo, String creditCartType, long creditCardNo) {
this.customerName = customerName;
this.driverLicenceNo = driverLicenceNo;
this.telephoneNo = telephoneNo;
this.creditCartType = creditCartType;
this.creditCardNo = creditCardNo;
}
public String getCustomerName() {
return customerName;
}
public String getDriverLicenceDate() {
return driverLicenceDate;
}
public int getDriverLicenceNo() {
return driverLicenceNo;
}
public String getTelephoneNo() {
return telephoneNo;
}
public String getCreditCartType() {
return creditCartType;
}
public long getCreditCardNo() {
return creditCardNo;
}
public void setTelephoneNo(String telephoneNo) {
this.telephoneNo = telephoneNo;
}
public void setCreditCartType(String creditCartType) {
this.creditCartType = creditCartType;
}
public void setCreditCardNo(long creditCardNo) {
this.creditCardNo = creditCardNo;
}
@Override
public String toString() {
return "Customer [customerName=" + customerName + ", driverLicenceNo="
+ driverLicenceNo + ", telephoneNo=" + telephoneNo
+ ", creditCartType=" + creditCartType + ", creditCardNo="
+ creditCardNo + "]";
}
}
*****************************************************************************************
public class Rental {
private String rentalClassName;
private double dailyRate;
private double weeklyRate;
public Rental(String rentalClassName, double dailyRate, double weeklyRate) {
this.rentalClassName = rentalClassName;
this.dailyRate = dailyRate;
this.weeklyRate = weeklyRate;
}
public String getRentalClassName() {
return rentalClassName;
}
public void setRentalClassName(String rentalClassName) {
this.rentalClassName = rentalClassName;
}
public double getDailyRate() {
return dailyRate;
}
public void setDailyRate(double dailyRate) {
this.dailyRate = dailyRate;
}
public double getWeeklyRate() {
return weeklyRate;
}
public void setWeeklyRate(double weeklyRate) {
this.weeklyRate = weeklyRate;
}
@Override
public String toString() {
return "Rental [rentalClassName=" + rentalClassName + ", dailyRate="
+ dailyRate + ", weeklyRate=" + weeklyRate + "]";
}
}
**********************************************************************
public class Vehicle {
private String model;
private String tagIssuedState;
private String tagNumber;
private Rental rental;
public Vehicle(String model, String tagIssuedState, String tagNumber,
Rental rental) {
this.model = model;
this.tagIssuedState = tagIssuedState;
this.tagNumber = tagNumber;
this.rental = rental;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public String getTagIssuedState() {
return tagIssuedState;
}
public void setTagIssuedState(String tagIssuedState) {
this.tagIssuedState = tagIssuedState;
}
public String getTagNumber() {
return tagNumber;
}
public void setTagNumber(String tagNumber) {
this.tagNumber = tagNumber;
}
public Rental getRental() {
return rental;
}
public void setRental(Rental rental) {
this.rental = rental;
}
@Override
public String toString() {
return "Vehicle [model=" + model + ", tagIssuedState=" + tagIssuedState
+ ", tagNumber=" + tagNumber + ", rental=" + rental + "]";
}
}
***********************************************************************
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.Scanner;
public class RentalAgreement {
private Customer customer;
private LocalDateTime outDateTime;
private LocalDateTime inDateTime;
public RentalAgreement(Customer customer) {
this.customer = customer;
}
public Customer getCustomer() {
return customer;
}
public LocalDateTime getOutDateTime() {
return outDateTime;
}
public LocalDateTime getInDateTime() {
return inDateTime;
}
public void setOutDateTime(LocalDateTime outDateTime) {
this.outDateTime = outDateTime;
}
public void setInDateTime(LocalDateTime inDateTime) {
this.inDateTime = inDateTime;
}
public double getRentalCharge(int noofDays, double d) {
double charge = noofDays * d;
return charge;
}
private double getAirportTax(int noofdays) {
return noofdays * 15.00;
}
private double getSalesTax(int noofDays) {
return noofDays * 0.06;
}
private double getTotal(double rentalcharge, double airporttax,
double totaltax) {
return rentalcharge + airporttax + totaltax;
}
@Override
public String toString() {
return "RentalAgreement [customer=" + customer + ", outDateTime="
+ outDateTime + ", inDateTime=" + inDateTime + "]";
}
public static void main(String[] args) {
System.out.println("enter the customer details");
Scanner scanner = new Scanner(System.in);
System.out.println("enter the customername");
String customerName = scanner.next();
System.out.println("enter customer driving licence no");
int driverLicenceNo = scanner.nextInt();
System.out.println("enter the mobileno");
String telephoneNo = scanner.next();
System.out.println("enter the creditcard type");
String creditCartType = scanner.next();
System.out.println("enter the customer credit card no");
long creditCardNo = scanner.nextLong();
Customer customer = new Customer(customerName, driverLicenceNo,
telephoneNo, creditCartType, creditCardNo);
RentalAgreement agreement = new RentalAgreement(customer);
LocalDateTime datetimeout = LocalDateTime.of(2017, 1, 10, 8, 45);
agreement.setOutDateTime(datetimeout);
LocalDateTime datetimein = LocalDateTime.of(2017, 1, 11, 8, 45);
agreement.setInDateTime(datetimein);
int noofDays = (int) Duration.between(datetimeout, datetimein)
.plusMinutes(23 * 60).toDays();
System.out.println(noofDays);
System.out.println("enter rental class name");
String rentalClassName = scanner.next();
System.out.println("enter dailyrate");
double dailyRate = scanner.nextDouble();
System.out.println("enter weeklyRate");
double weeklyRate = scanner.nextDouble();
System.out.println("enter the model");
String model = scanner.next();
System.out.println("enter tagissuedstate");
String tagIssuedState = scanner.next();
System.out.println("enter the tag no ");
String tagNumber = scanner.next();
Rental rental = new Rental(rentalClassName, dailyRate, weeklyRate);
Vehicle vehicle = new Vehicle(model, tagIssuedState, tagNumber, rental);
double rentalcharge = agreement.getRentalCharge(noofDays,
rental.getDailyRate());
double airporttax = agreement.getAirportTax(noofDays);
double tax = agreement.getSalesTax(noofDays);
double totaltax = agreement.getTotal(rentalcharge, airporttax, tax);
System.out.println(customer.toString());
System.out.println(rental.toString());
System.out.println(vehicle.toString());
System.out.println("the rental charge is $" + rentalcharge);
System.out.println("the rental charge is $" + airporttax);
System.out.println("the rental charge is $" + tax);
System.out.println("the rental charge is $" + totaltax);
System.out.println(agreement.toString());
}
}
output
//as per the user supplied data the output will come
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.