package com.imooc;
public class Bus {
int id;
String name;
String money;
String cap;
public void bus(int id,String name,String money,String cap){
this.id=id; this.name=name; this.money=money; this.cap=cap;
System.out.println(id+"\t"+name+"\t"+money+"\t"+cap);
}
}
package com.imooc;
import java.util.Scanner;
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("欢迎使用答答租车系统:");
System.out.println("您是否要租车:1.是\t0.否");
while(true){
Scanner x1=new Scanner(System.in);
int x=x1.nextInt();
if(1==x){
System.out.println("您可租车的类型及其价格表:");
System.out.println("序号\t"+"汽车名称\t"+"租金\t"+"容量");
Bus bus1=new Bus();
Bus bus2=new Bus();
Bus bus3=new Bus();
bus1.bus(1,"奥迪A4","500元/天","载人:4人");
bus2.bus(2, "皮卡雪6", "450元/天","载人:4人 载货:2吨");
bus3.bus(3, "松花江", "400元/天", "4吨");
System.out.println("请输入你要租车的数量:");
Scanner y1=new Scanner(System.in);
int y=y1.nextInt();
int[] q = new int[y];
for(int i=0;i<q.length;i++){
System.out.println("请输入第"+(i+1)+"辆车的序号:");
Scanner q1=new Scanner(System.in);
q[i]=q1.nextInt();
}
System.out.println("请输入租车天数:");
Scanner z1=new Scanner(System.in);
int z=z1.nextInt();
System.out.println("您的账单如下:");
int peoples=0;
int goods=0;
int prices=0;
for(int j=0;j<q.length;j++){
if(1==q[j]){
System.out.print("奥迪A4\t");
peoples+=4;
prices=z*500+prices;
}
else if(2==q[j]){
System.out.print("皮卡雪6\t");
peoples+=4; goods+=2;
prices=z*450+prices;
}
else if(3==q[j]){
System.out.print("松花江\t");
goods+=4;
prices=z*400+prices;
}
}
System.out.println("\n共载人:"+peoples+"人");
System.out.println("共载货:"+goods+"吨");
System.out.println("租车总价格为:"+prices+"元");
System.out.println("欢迎使用答答租车系统,谢谢再见!");
}
else if(0==x)
System.out.println("谢谢使用,再见!");
else{
System.out.println("输入错误!");
System.out.println("请重新输入:");
}
}
}
}
热门评论
看以前自己写的这个,好简单。。当时的自己以为如临大敌,哈哈