Advertisement
Guest User

Main

a guest
Nov 25th, 2014
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. import javax.swing.*;
  2. import java.util.Scanner;
  3.  
  4. public class UseCarRental
  5. {
  6. public static void main(String args[]) //throws Exception
  7. {
  8. int days;
  9. String name, luxurySelection;
  10. int zipCode;
  11. String size;
  12.  
  13. Scanner inputDevice = new Scanner(System.in);
  14.  
  15. System.out.println("Enter days you'll be renting the car: ");
  16. days= inputDevice.nextInt();
  17.  
  18. System.out.println("Enter your name: ");
  19. name = inputDevice.next();
  20.  
  21. System.out.println("Enter your zip code: ");
  22. inputDevice.nextLine();
  23. zipCode = inputDevice.nextInt();
  24.  
  25. System.out.println("Enter size of car you'd like to rent (e for economy, m for midsize, f for fullsize): ");
  26. size = inputDevice.next();
  27.  
  28. System.out.println("Would you like a luxury vehicle? Y/N : ");
  29. luxurySelection = inputDevice.next();
  30.  
  31. if (luxurySelection.toLowerCase() == "Y")
  32. {
  33. LuxuryCarRental luxury = new LuxuryCarRental(name, zipCode, size, days);
  34. double cfee = luxury.chauffer();
  35. luxury.setFee(cfee);
  36. luxury.calculateTotal();
  37. luxury.display();
  38. }
  39. else
  40. {
  41. CarRental econ = new CarRental(name, zipCode, size, days);
  42. econ.calculateTotal(days);
  43. econ.display();
  44. }
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement