<pre>/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package carsrental; import java.util.Scanner; import java.util.ArrayList; /** * * @author رغد */ public class CarsRental { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here int choice; int color; int pay; String year, first, last, phone; double duration; Scanner input = new Scanner(System.in); Car c1 = new Car(); prsonalInformation p1 = new prsonalInformation(); Money m1 = new Money(); System.out.println("---------------------------------------"); System.out.println("----------Welcome to ray cars----------"); System.out.println("---------------------------------------"); System.out.println("The cars:"); System.out.println("1.Mercedes"); System.out.println("2.Mazda"); System.out.println("Enter your choice: "); choice = input.nextInt(); if (choice == 1) { c1.setMake("Mercedes"); System.out.println(">>The price of one day: " + c1.getPrice1()); } else if (choice == 2) { c1.setMake("Mazda"); System.out.println(">>The price of one day: " + c1.getPrice2()); } else { while (choice > 2) { System.out.println("That number is invalid."); System.out.println("Please Enter again a choice 1 or 2"); choice = input.nextInt(); } } System.out.println("The color of car:"); System.out.println("1.Black"); System.out.println("2.blue"); System.out.println("Enter your choice: "); color = input.nextInt(); if (color == 1) { c1.setColor("Black"); } else if (color == 2) { c1.setColor("blue"); } input.nextLine(); System.out.println("Enter the year modal of cars: "); year = input.nextLine(); c1.setYearMOdal(year); System.out.println("Enter your first name: "); first = input.nextLine(); p1.setFirstName(first); System.out.println("Enter your last name: "); last = input.nextLine(); p1.setLastName(last); System.out.println("Enter your phone number: "); phone = input.nextLine(); p1.setPhoneNumber(phone); System.out.println("The way of payment: "); System.out.println("1.Apple pay "); System.out.println("2.Mastercard"); System.out.println("Enter your choice: "); pay = input.nextInt(); if (pay == 1) { m1.setPayment("Apple pay "); } else if (pay == 2) { m1.setPayment("Mastercard"); } if (choice == 1) { c1.getPrice1(); } else if (choice == 2) { c1.getPrice2(); } System.out.println("How many days you want?"); duration = input.nextDouble(); Renting r1 = new Renting(duration); Renting r2 = new Renting(p1); Renting r3 = new Renting(c1); Renting r4 = new Renting(m1); r1.setDuration(duration); if (choice == 1) { m1.setBalance(c1.getPrice1() * duration); } else if (choice == 2) { m1.setBalance(c1.getPrice2() * duration); } ArrayList<Renting> list = new ArrayList<Renting>(); list.add(r1); list.add(r2); list.add(r3); list.add(r4); System.out.println("-----Your bill-----"); for (Renting r : list) { System.out.println(r.getPerson()); System.out.println(r.getcar()); System.out.println(r.getmo()); } System.out.println("-----Thank you!!-----"); } }
run: --------------------------------------- ----------Welcome to ray cars---------- --------------------------------------- The cars: 1.Mercedes 2.Mazda Enter your choice: 2 >>The price of one day: 250 The color of car: 1.Black 2.blue Enter your choice: 1 Enter the year modal of cars: 2020 Enter your first name: nawaf Enter your last name: alkhadidi Enter your phone number: 05555555555 The way of payment: 1.Apple pay 2.Mastercard Enter your choice: 1 How many days you want? 3 -----Your bill----- null null null >>The pesonal information The fisrt name is: nawaf The last name is: alkhadidi The phone number: 05555555555 null null null >>The car information The company make is: Mazda The Year Modal is: 2020 The color is: Black null null null >>The payment information The way of payment: Apple pay You have to payment: 750.0 -----Thank you!!----- BUILD SUCCESSFUL (total time: 29 seconds)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)