Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- import java.util.Scanner;
- public class UseCarRental
- {
- public static void main(String args[]) //throws Exception
- {
- int days;
- String name, luxurySelection;
- int zipCode;
- String size;
- Scanner inputDevice = new Scanner(System.in);
- System.out.println("Enter days you'll be renting the car: ");
- days= inputDevice.nextInt();
- System.out.println("Enter your name: ");
- name = inputDevice.next();
- System.out.println("Enter your zip code: ");
- inputDevice.nextLine();
- zipCode = inputDevice.nextInt();
- System.out.println("Enter size of car you'd like to rent (e for economy, m for midsize, f for fullsize): ");
- size = inputDevice.next();
- System.out.println("Would you like a luxury vehicle? Y/N : ");
- luxurySelection = inputDevice.next();
- if (luxurySelection.toLowerCase() == "Y")
- {
- LuxuryCarRental luxury = new LuxuryCarRental(name, zipCode, size, days);
- double cfee = luxury.chauffer();
- luxury.setFee(cfee);
- luxury.calculateTotal();
- luxury.display();
- }
- else
- {
- CarRental econ = new CarRental(name, zipCode, size, days);
- econ.calculateTotal(days);
- econ.display();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement