Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.78 KB | None | 0 0
  1. //Program.java
  2. package application;
  3.  
  4. import java.text.ParseException;
  5. import java.text.SimpleDateFormat;
  6. import java.util.Date;
  7. import java.util.Locale;
  8. import java.util.Scanner;
  9. import model.entities.CarRental;
  10. import model.entities.Vehicle;
  11. import model.service.BrazilTaxService;
  12. import model.service.RentalService;
  13.  
  14. public class Program {
  15.     public static void main(String[] args) throws ParseException {
  16.         Locale.setDefault(Locale.US);
  17.        
  18.         Scanner sc = new Scanner(System.in);
  19.         SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm");
  20.        
  21.         System.out.println("Enter the rental data:");
  22.        
  23.         System.out.println("Car model:");
  24.         String carModel = sc.nextLine();
  25.         System.out.println("Pickup (dd/MM/yyyy hh:mm): ");
  26.         Date start = sdf.parse(sc.nextLine());
  27.         System.out.println("return (dd/MM/yyyy hh:mm): ");
  28.         Date finish = sdf.parse(sc.nextLine());
  29.        
  30.         CarRental cr = new CarRental(start, finish, new Vehicle(carModel));
  31.        
  32.         System.out.println("Enter price per hour:");
  33.         double pricePerHour = sc.nextDouble();
  34.         System.out.println("Enter price per Day:");
  35.         double pricePerDay = sc.nextDouble();
  36.        
  37.         RentalService rentalService = new RentalService(pricePerDay, pricePerHour, new BrazilTaxService());
  38.         rentalService.processInvoice(cr);
  39.        
  40.         System.out.println("INVOICE");
  41.         System.out.println("basic Payment "+String.format("%.2f", cr.getInvoice().getBasicPayment()));
  42.         System.out.println("tax "+String.format("%.2f", cr.getInvoice().getTax()));
  43.         System.out.println("total Payment "+String.format("%.2f", cr.getInvoice().getTotalPayment()));
  44.        
  45.         sc.close();
  46.        
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement