首页 > 代码库 > 租车公司系统demo

租车公司系统demo

import java.util.*;
class Car
{
 String[] name =new String[5]; 
 int num1=0;
 int num2=0;
 int num3=0;
 int num4=0;
 int num5=0;
 int money=0;
 int n1=0;
 int n2=0;
 int n3=0;
 int n4=0;
 int n5=0;

 public void CarList(){
    System.out.println("************************************************");
   System.out.println("欢迎来到xx汽车租赁公司。清单如下请看:");
   System.out.println("1.别克商务舱GL8 ----------------------- 600元/天");
   System.out.println("2.宝马550i----------------------------- 500元/天");
   System.out.println("3.别克林荫大道------------------------- 300元/天" );
   System.out.println("4.客车(金杯、金龙) <=16座------------ 800元/天");
   System.out.println("5.客车(金杯、金龙) >16座 ------------ 1500元/天");
   System.out.println("请你输入以上车对应的数字 进行选择你要租赁的车");
    System.out.println("************************************************");
   selectCar();
 }

   public void selectCar(){
   Scanner input = new Scanner(System.in);
   int option = input.nextInt();
   switch (option){
   case 1:
       System.out.println("************************************************");
       System.out.println("你选择的是别克商务舱GL8");
       jCar1();
        retunCar();
       System.out.println("************************************************");
    break;
   case 2:
       System.out.println("************************************************");
       System.out.println("你选择的是.宝马550i");
       jCar2();
        retunCar();
        System.out.println("************************************************");
    break;
   case 3:
       System.out.println("************************************************");
       System.out.println("你选择的是别克林荫大道");
    jCar3();
     retunCar();
       System.out.println("************************************************");
    break;
   case 4:
       System.out.println("************************************************");
       System.out.println("你选择的是客车(金杯、金龙) <=16座");
    jCar4();
     retunCar();
       System.out.println("************************************************");
    break;
   case 5:
       System.out.println("************************************************");
       System.out.println("你选择的是客车(金杯、金龙) >16座 ");
    jCar5();
     retunCar(); 
       System.out.println("************************************************");
    break;
   case 6:
       System.out.println("退出");
     break;
   default:
      System.out.println("请真确输入");
   }

   }


  public void jCar1(){
   System.out.println("************************************************");
   System.out.println("你要租几辆");
   Scanner i = new Scanner(System.in);
   n1= i.nextInt();
    System.out.println("************************************************");
   System.out.println("你要租几天");
   Scanner input =new Scanner(System.in);
   num1 =input.nextInt();
    System.out.println("************************************************");
   System.out.println("你一共租了"+n1+"辆别克商务舱GL8,"+"天数是"+num1+"天;"+"一共是"+(n1*num1*600)+"元");
  }

 public void jCar2(){
   System.out.println("************************************************");
   System.out.println("你要租几辆");
   Scanner i = new Scanner(System.in);
   n2= i.nextInt();
   System.out.println("************************************************");
   System.out.println("你要租几天");
   Scanner input =new Scanner(System.in);
   num2 =input.nextInt();
   System.out.println("************************************************");
    System.out.println("你一共租了"+n2+"辆别克商务舱GL8,"+"天数是"+"天;"+num2+"一共是"+(n2*num2*600)+"元");
  }

   public void jCar3(){
    System.out.println("************************************************");
    System.out.println("你要租几辆");
    Scanner i = new Scanner(System.in);
    n3= i.nextInt();
    System.out.println("************************************************");
    System.out.println("你要租几天");
    Scanner input =new Scanner(System.in);
    num3 =input.nextInt();
    System.out.println("************************************************");
    System.out.println("你一共租了"+n3+"辆别克商务舱GL8,"+"天数是"+"天;"+num3+"一共是"+(n3*num3*600)+"元");

  }


   public void jCar4(){
   System.out.println("************************************************");
   System.out.println("你要租几辆");
   Scanner i = new Scanner(System.in);
   n4= i.nextInt();
   System.out.println("************************************************");
   System.out.println("你要租几天");
   Scanner input =new Scanner(System.in);
   num4 =input.nextInt();
   System.out.println("************************************************");
 System.out.println("你一共租了"+n4+"辆别克商务舱GL8,"+"天数是"+"天;"+num4+"一共是"+(n4*num4*600)+"元");

  }
   public void jCar5(){
   System.out.println("************************************************");
   System.out.println("你要租几辆");
   Scanner i = new Scanner(System.in);
   n5= i.nextInt();
   System.out.println("************************************************");
   System.out.println("你要租几天");
   Scanner input =new Scanner(System.in);
   num5 =input.nextInt();
   System.out.println("************************************************");
   System.out.println("你一共租了"+n5+"辆别克商务舱GL8,"+"天数是"+"天;"+num5+"一共是"+(n5*num5*600)+"元");

  }

  public void retunCar(){
   System.out.println("还要租别的车吗?输入 1.是的。 输入 0 不需要了");
   Scanner input =new Scanner(System.in);
   int or = input.nextInt();
   if(or==1){
     CarList();
   }else if(or==0){
       money =n1*num1*600+n2*num2*500+n3*num3*300+n4*num4*800+n5*num5*1600;
     System.out.println("谢谢,一共是"+money+"元.");  
     System.out.println("祝你旅程愉快");
   }else{
     System.out.println("请正确输入");
     retunCar();
   }

  
  }


}


class demoCar 
{
    public static void main(String[] args) 
    {

        Car car =new Car();
        car.CarList();
        
    }
}

 

租车公司系统demo