租车系统

  1 package cars;
  2 
  3 import java.util.Scanner;
  4 
  5 public class RentTest {
  6     static int  result1=0;
  7     static int  result2=0;
  8     public static void main(String[] args) {
  9         // TODO Auto-generated method stub
 10         //int a;
 11         Cars c1 = new Cars();
 12         Cars c2 = new Cars();
 13         Cars c3 = new Cars();
 14         Cars c4 = new Cars();
 15         Cars c5 = new Cars();
 16         Cars c6 = new Cars();
 17         c1.money=500;
 18         c1.capacity1=4;
 19         c1.name="奥迪A4";
 20         c2.money=400;
 21         c2.capacity1=4;
 22         c2.name="马自达6";
 23         c3.money=450;
 24         c3.capacity1=4;
 25         c3.capacity2=2;
 26         c3.name="皮卡雪6";
 27         c4.money=800;
 28         c4.capacity1=20;
 29         c4.name="金龙";
 30         c5.money=400;
 31         c5.capacity1=4;
 32         c5.name="松花江";
 33         c6.money=1000;
 34         c6.capacity1=20;
 35         c6.name="依维柯";
 36         System.out.println("欢迎使用答答租车系统:");
 37         System.out.println("您是否要租车:1是   0否");
 38         Scanner sc = new Scanner(System.in);
 39         
 40         int a = sc.nextInt();
 41         if(a==0) System.exit(-1);
 42         if(a==1){
 43             System.out.println("您可出租的类型和价目表");
 44             System.out.println("序号    汽车类型     租金          容量");
 45             System.out.println("1.   奥迪A4   500元一天   载人:4人");
 46             System.out.println("2.   马自达6   400元一天   载人:4人");
 47             System.out.println("3.   皮卡雪   450元一天   载人:4人,载货:2");
 48             System.out.println("4.   金龙   800元一天   载人:20人");
 49             System.out.println("5.   松花江   400元一天   载人:4人");
 50             System.out.println("6.   依维柯   1000元一天   载人:20人");
 51         }
 52         System.out.println("数量");
 53         int b =sc.nextInt();
 54         int []tmp=new int[100];
 55         for(int i=0;i<b;i++){
 56             System.out.println("请输入第"+(i+1)+"辆车的序号");
 57             //sc.nextInt();
 58              tmp[i]=sc.nextInt();
 59             //System.out.println(sc.nextInt());
 60             
 61         }
 62     
 63         
 64         System.out.println("请输入租车天数:");
 65         sc.nextInt();
 66         //System.out.println(sc.nextInt());
 67         sc.close();
 68         System.out.println("您的账单:");
 69         System.out.println("***可载人的有:");
 70         Cars []c=new Cars [6];
 71         c[0]=c1;
 72         c[1]=c2;
 73         c[2]=c3;
 74         c[3]=c4;
 75         c[4]=c5;
 76         c[5]=c6;
 77         //for()
 78         
 79         for(int j=0;j<b;j++){
 80             
 81             System.out.println(c[tmp[j]-1].name);
 82             
 83         }
 84         for(int jj=0;jj<b;jj++){
 85             result1+=c[tmp[jj]-1].capacity1;
 86         
 87         }
 88         
 89         System.out.println("共载人:"+result1);
 90         
 91         int count=0;
 92         System.out.println("***可载货的有:");
 93         for(int j2=0;j2<b;j2++){
 94             if(tmp[j2]==2){
 95                 System.out.println(c[2].name);
 96                 count++;        
 97         }
 98         
 99         } 
100         if(count==0){
101             System.out.println("0");
102         }
103         
104         for(int jjj=0;jjj<b;jjj++){
105             result2+=c[tmp[jjj]-1].money;
106         
107         }
108         
109         System.out.println("***租车总价格为:"+result2);
110     }
111 }

 

 1 package cars;
 2 
 3 public  class Cars {
 4     public int money;
 5     public  int capacity1;
 6     public int capacity2;
 7 
 8     public String name;
 9 
10 }

 

posted @ 2017-02-25 13:42  芊鸟咔咔  阅读(283)  评论(0编辑  收藏  举报