Autoboxing and Unboxing
Autoboxing and Unboxing
*;
public class carrent
{
static void main()
{
Scanner sc= new Scanner(System.in);
draw.drawline(100);
System.out.println("CAR RENTAL SERVICE");
draw.drawline(100);
System.out.println("A. Car Models");
System.out.println("B. Search for Model");
System.out.println("C. Rent a Car");
draw.drawline(100);
String car[]= {"Lamborghini Aventador","Audi R8","BMW M8","Tesla
Model X","Lexus GX 460"};//array storing car model
int rent[]= {500,200,150,150,50};//array storing rent
int stock[]= {0,10,10,10,50};//array storing amount of cars available for
the respective
String name= "";
int days=0;
int amt=0;
String date="";
String model="";
boolean run = false;
while(run==false)
{
String op= sc.nextLine();// to accpet users choice
if(op.equalsIgnoreCase("a"))
{
for(int i= 0;i<=4;i++)
{
draw.drawline(100);
System.out.println("Car Model:"+car[i]);
System.out.println(";Number available:"+stock[i]);
System.out.println("Rent(per day) in $: "+rent[i]);
//draw.drawline(100);
}
draw.drawline(100);
}
else if(op.equalsIgnoreCase("b"))
{
System.out.println("Enter model of the car"); ;
boolean sr= false;
while(sr==false)
{
String md= sc.nextLine();
for(int i=0;i<=4;i++)
{
if(md.equalsIgnoreCase(car[i]))
{
draw.drawline(100);
System.out.println("Car Model :"+car[i]);
System.out.println("Number available:"+stock[i]);
System.out.println("Rent (per day) in $:"+rent[i]);
draw.drawline(100);
sr=true;
break;
}
}
if(sr==false)
{
System.out.println("Model not found");
System.out.println("Please enter another model");
}
}
}
else if(op.equalsIgnoreCase("c"))
{
System.out.println("Enter the model of the car you would like to rent");
boolean chk=false;
while(chk==false)
{
String cm= sc.nextLine();
for(int i=0;i<=4;i++)
{
if(cm.equalsIgnoreCase(car[i]))
{
if(stock[i]>0)
{
model=car[i];
System.out.println("Please enter your name");
name= sc.nextLine();
System.out.println("How many days are you renting the car for?");
days= sc.nextInt();
System.out.println("Please enter todays date");
date= sc.nextLine();
amt=rent[i]*days;
stock[i]=stock[i]-1;
chk=true;
break;
}
else
{
System.out.println("Car is not in stock");
System.out.println("Please choose another model");
break;
}
}
}
if(chk==false)
{
System.out.println("enter the correct model");
}
}
draw.drawline(100);
System.out.println("Customer:"+name);
System.out.println("Car Model:"+model);
System.out.println("Date Rented:"+date);
System.out.println("The amount due is $"+amt);
draw.drawline(100);
run=true;
}
}