第一次写,用了什么也不懂,只是能实现,感觉懵的有些注释也懒得删了,感觉有些可以改进的,下次改,这次就这样先发出来了
import java.io.InputStream;
public class Car
{
//String
String str1 = "1\t 奥迪A4\500元/天\t\t载客:4人";
String str2 = "2\t马自达6\t400元/天\t\t载客:4人 ";
String str3 = "3\t金龙\t800元/天\t\t载人20";
String str4 = "4\t皮卡雪6\t450元/天\t\t载客4人;载货4吨 ";
String str5 = "5\t松花江 \t400元/天\t\t载货:4吨 ";
String str6 = "6\t依维柯\t1000元/天\t\t载货:20吨";
public void show1()
{
System.out.println(str1);
System.out.println(str2);
System.out.println(str3);
System.out.println(str4);
System.out.println(str5);
System.out.println(str6);
}
}
public class Dada
{
/**
* @param args
*/
public static void main(String[] args)
{
float money1 = 500;
float money2 = 400;
float money3 = 800;
float money4 = 450;
float money5 = 400;
float money6 = 1000;
String str="";
String ste="";
//String [] car1 ={"奥迪A4","马自达6","皮卡雪6","金龙","松花江","依维柯"};
/*String car1 = "奥迪A4";
String car2 = "马自达6";
String car3 = "皮卡雪6";
String car4 = "金龙";
String car5 = "松花江";
String car6 = "依维柯";
*/
// TODO Auto-generated method stub
System.out.println("您好!欢迎来到哒哒租车系统!");
System.out.println("请问您是否需要租车?不是请按0退出,按任意键进入租车界面。");
Scanner input = new Scanner(System.in);
int i = input.nextInt();
if(i==0)
{
System.out.println("再见!欢迎您下次使用哒哒租车系统");
}
else
{
System.out.println("可租车辆型号及价格表:");
System.out.println("序号\t汽车名称\t租金\t\t容量" );
//车辆信息方法调用,车辆信息表
Car car = new Car();
car.show1();
}
System.out.println("请输入您要租汽车的数量");
int num =input.nextInt();
float money = 0;
double weigth =0;
int sum = 0;
//定义空字符数组strr,便于下面用来赋值车辆名称
for (int j=1;j<=num;j++)
{
System.out.println("请输入第"+j+"量车的序号!");
int k =input.nextInt();
switch (k) {
case 1:money=money+money1; sum=sum+4; weigth=weigth+0; str+= "奥迪A4 ";
break;
case 2:money=money+money2; sum=sum+4; weigth=weigth+0; str+="马自达6";
break;
case 3:money=money+money3; sum=sum+4; weigth=weigth+2; ste+="皮卡雪6";
break;
case 4:money=money+money4; sum=sum+20; weigth=weigth+0; str+="金龙";
break;
case 5:money=money+money5; sum=sum+0; weigth=weigth+4; ste+="松花江";
break;
default:money=money+money6; sum=sum+0; weigth=weigth+20; ste+="依维柯";
break;
}
}
System.out.println("请输入所租天数:");
int day = input.nextInt();
System.out.println("您的账单为:");
System.out.println("***可载人的车辆有:\t"+str+"可载:"+sum+"人");
System.out.println("");//输出车辆信息
System.out.println("***载货的车有:\t"+ste+"可载货:"+weigth+"吨");
System.out.println("租车总价格为:"+money*day);
}
}