Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Develop car rental application may use to produce a receipt. A receipt will be f

ID: 3789917 • Letter: D

Question

Develop car rental application may use to produce a receipt. A receipt will be formatted E Z R I D E R Rental Receipt John Jones Customer Driver License PA 12343 Telephone 724-555-8345 Credit Card VISA 12345678012 Vehicle 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), card type (as String), and credit card number (as 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 ofinformation: 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 dateltime 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

package rentCar;

public class Coustomer {

   String coustomerName;
   String    driverLicenseState;
   int driverLicenseNo;
   String telephoneNo;
   String creditCardType;
   Long creditcardNo;
   public Coustomer(String coustomerName, String driverLicenseState,
           int driverLicenseNo, String telephoneNo, String creditCardType,
           Long creditcardNo) {
       super();
       this.coustomerName = coustomerName;
       this.driverLicenseState = driverLicenseState;
       this.driverLicenseNo = driverLicenseNo;
       this.telephoneNo = telephoneNo;
       this.creditCardType = creditCardType;
       this.creditcardNo = creditcardNo;
   }
  
   public String getCoustomerName() {
       return coustomerName;
   }

   public String getDriverLicenseState() {
       return driverLicenseState;
   }

   public int getDriverLicenseNo() {
       return driverLicenseNo;
   }

   public String getTelephoneNo() {
       return telephoneNo;
   }

   public String getCreditCardType() {
       return creditCardType;
   }

   public Long getCreditcardNo() {
       return creditcardNo;
   }

   public void setTelephoneNo(String telephoneNo) {
       this.telephoneNo = telephoneNo;
   }
   public void setCreditCardType(String creditCardType) {
       this.creditCardType = creditCardType;
   }
   public void setCreditcardNo(Long creditcardNo) {
       this.creditcardNo = creditcardNo;
   }
  
  
}

package rentCar;

public class RentalClass {
  
   String rentalClassName;
   double dailyRate;
   double weeklyRate;
   public RentalClass(String rentalClassName, double dailyRate,
           double weeklyRate) {
       super();
       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;
   }
  

}

package rentCar;

public class Vehicle {
  
   String makeModel;
   String stateIssuing;
   String tagNumber;
   RentalClass rentalClass;
   public Vehicle(String makeModel, String stateIssuing, String tagNumber) {
       super();
       this.makeModel = makeModel;
       this.stateIssuing = stateIssuing;
       this.tagNumber = tagNumber;
      
   }
   public String getMakeModel() {
       return makeModel;
   }
   public void setMakeModel(String makeModel) {
       this.makeModel = makeModel;
   }
   public String getStateIssuing() {
       return stateIssuing;
   }
   public void setStateIssuing(String stateIssuing) {
       this.stateIssuing = stateIssuing;
   }
   public String getTagNumber() {
       return tagNumber;
   }
   public void setTagNumber(String tagNumber) {
       this.tagNumber = tagNumber;
   }
   public RentalClass getRentalClass() {
       return rentalClass;
   }
   public void setRentalClass(RentalClass rentalClass) {
       this.rentalClass = rentalClass;
   }

}

package rentCar;

import java.time.Duration;
import java.time.LocalDateTime;

public class RentalAgreement {
   Coustomer coustomer;
   RentalClass rentalClass;
   Vehicle vehicle;
   LocalDateTime dateTimeOut;
   LocalDateTime dateTimeIn;
   public RentalAgreement(Coustomer coustomer, Vehicle vehicle,
           LocalDateTime dateTimeOut) {
      
       this.coustomer = coustomer;
       this.vehicle = vehicle;
       this.dateTimeOut = dateTimeOut;
   }
   public Coustomer getCoustomer() {
       return coustomer;
   }
   public Vehicle getVehicle() {
       return vehicle;
   }
   public LocalDateTime getDateTimeOut() {
       return dateTimeOut;
   }
   public LocalDateTime getDateTimeIn() {
       return dateTimeIn;
   }
   public void setDateTimeIn(LocalDateTime dateTimeIn) {
       this.dateTimeIn = dateTimeIn;
   }
  
   public double getRentalCharge(){
       double rentalCharge = 0.0;
         
       int noODays = (int) Duration.between(dateTimeOut, dateTimeIn).plusMinutes(23*60).toDays();
       int noOfWeek =noODays/7;
       int remaingDay = noODays%7;
       if(noODays<6){
           rentalCharge = noODays*rentalClass.getDailyRate();
       }
       else if(noOfWeek>0&& noODays==0){
           rentalCharge = noOfWeek*rentalClass.getWeeklyRate();
          
       }
       else {
           rentalCharge = noOfWeek*rentalClass.getWeeklyRate() + remaingDay*rentalClass.getDailyRate();
       }
       return rentalCharge;
              
   }
   public double getAirportTax(){
       int noODays = (int) Duration.between(dateTimeOut, dateTimeIn).plusMinutes(23*60).toDays();
       double airportCharge = noODays*15;
       return airportCharge;
   }
   public double getSalesTax(){
       double tax= (getRentalCharge()*6/100);
       return tax;
   }
   public double getTotal(){
       double total = getRentalCharge() + getAirportTax()+getSalesTax();
       return total;
   }
   public void printReciept(){
      
       System.out.println( " EZ RIDER " );
       System.out.println(" Rental Receipt ");
       System.out.println(" Coustomer : " + coustomer.getCoustomerName());
       System.out.println(" DriverLicense : " + coustomer.getDriverLicenseNo());
       System.out.println(" Credit Card : " + coustomer.getCreditCardType() +" "+coustomer.getCreditcardNo());;
       System.out.println(" Vehicle : " + vehicle.getMakeModel());
       System.out.println(" Tag # : " + vehicle.getTagNumber());
       System.out.println(" RentClass : " + rentalClass.getRentalClassName());
       System.out.println(" Daily Rate : $" + rentalClass.getDailyRate());
       System.out.println(" weekly Rate : $" + rentalClass.getWeeklyRate());
       System.out.println(" Datetime Out : " +getDateTimeOut());
       System.out.println(" Datetime Out : " +getDateTimeIn());
       System.out.println(" Rental Charge : $ " +getRentalCharge());
       System.out.println(" Airport Tax : $ " +getAirportTax());
       System.out.println(" Salex Tax : $ " +getSalesTax());
       System.out.println(" Total Charge : $ " +getTotal());
   }

}

package rentCar;

import java.time.LocalDateTime;

public class TestClass {
static   RentalAgreement re;

   public static void main(String[] args) {
       // TODO Auto-generated method stub
       Coustomer newCoust = new Coustomer("Rakesh", "pune", 12345, "3445679l", "visa",456546457l);
       RentalClass rentClass = new RentalClass("Luxury", 95, 545);
       Vehicle vehicle = new Vehicle("Audi","pune", "ZA 8999");
       LocalDateTime dateTimeO = LocalDateTime.of(2017, 02, 17, 12, 34);
       RentalAgreement first = new RentalAgreement(newCoust, vehicle, dateTimeO);
       LocalDateTime dateTimeIn = LocalDateTime.of(2017,02,29,15,23);
       re.setDateTimeIn(dateTimeIn);
       re.printReciept();

   }

}