源码。。.
package com.zhuche;
import java.util.Scanner;
public class dada {
static int b;
public dada() {
}
// 反射会调用无参;
public dada(int b) {
this.b = b;
}
public static void main(String[] args) {
System.out.println("选择1进入系统,选择0退出系统");
Scanner in = new Scanner(System.in);
int a = in.nextInt();
if (a == 1) {
System.out.println("你可租用的车的类型及其价目表:");
System.out.println("序号" + " 汽车名称" + " 租金" + " 容量");
System.out.println("1." + " 奥迪A4" + " 500元/天" + " 载人:4人");
System.out.println("2." + " 马自达6" + " 400元/天" + " 载人:4人");
System.out.println("3." + " 皮卡雪6" + " 450元/天" + " 载人:4吨");
System.out.println("4." + " 金龙" + " 800元/天" + " 载人:20人");
System.out.println("5." + " 松花江" + " 400元/天" + " 载人:4吨");
System.out.println("6." + " 依维柯" + " 1000元/天" + " 载人:20吨");
} else {
System.exit(0);
}
customer h = new customer();
dada h2 = new dada(a);
System.out.println("天数:");
h.tianshu();
System.out.println("请输入要租用的车的数量");
h.shuliang();
h.totalprice();
h.totalchexing();
h.zaikeliang();
h.zaihuoliang();
System.out.println("***可载人的车有:");
h.zaike();
System.out.println("***可载货的车有:");
h.zaihuo();
}
}package com.zhuche;
import java.util.Scanner;
public class customer extends dada {
public customer() {
}
static String[] chexing = { "奥迪A4", "马自达6", "皮卡雪6", "金龙", "松花江", "依维柯" };
static int[] qian = { 500, 400, 450, 800, 400, 1000 };
int[] renshu = { 4, 4, 20 };
int[] dunwei = { 4, 4, 20 };
int zaihuoliang;
int totalprice;
int totalzaihuiliang;
int tianshu;
int sum;
int sumrenshu;
String a = " ";
String zaike = " ";
String zaihuo = " ";
int c;
public void xuanche() {
Scanner in = new Scanner(System.in);
int b = in.nextInt();
if (1 <= b && b <= c) {
if (b == 1) {
System.out.println("车型:" + chexing[0] + " 价钱为:" + qian[0]
+ " 载人:" + renshu[0] + "人");
// System.out.println(qian[0]*tianshu);
sum += qian[0] * tianshu;
a += chexing[0];
sumrenshu += renshu[0];
zaike += chexing[0];
}
if (b == 2) {
System.out.println("车型:" + chexing[1] + " 价钱为:" + qian[1]
+ " 载人:" + renshu[1] + "人");
sum += qian[1] * tianshu;
a += chexing[1];
sumrenshu += renshu[1];
zaike += chexing[1];
}
if (b == 3) {
System.out.println("车型:" + chexing[2] + " 价钱为:" + qian[2]
+ " 载货:" + dunwei[0] + "吨");
sum += qian[2] * tianshu;
a += chexing[2];
totalzaihuiliang += dunwei[0];
zaihuo += chexing[2];
}
if (b == 4) {
System.out.println("车型:" + chexing[3] + " 价钱为:" + qian[3]
+ " 载人:" + renshu[2] + "人");
sum += qian[3] * tianshu;
a += chexing[3];
sumrenshu += renshu[2];
zaike += chexing[3];
}
if (b == 5) {
System.out.println("车型:" + chexing[4] + " 价钱为:" + qian[4]
+ " 载货:" + dunwei[1] + "吨");
sum += qian[4] * tianshu;
a += chexing[4];
totalzaihuiliang += dunwei[1];
zaihuo += chexing[4];
}
if (b == 6) {
System.out.println("车型:" + chexing[5] + " 价钱为:" + qian[5]
+ " 载货:" + dunwei[2] + "吨");
sum += qian[5] * tianshu;
a += chexing[5];
totalzaihuiliang += dunwei[2];
zaihuo += chexing[5];
}
} else {
System.out.println("请重新输入车辆的编号!");
Scanner in3 = new Scanner(System.in);
b = in3.nextInt();
if (1 <= b && b <= c) {
if (b == 1) {
System.out.println("车型:" + chexing[0] + " 价钱为:" + qian[0]
+ " 载人:" + renshu[0] + "人");
// System.out.println(qian[0]*tianshu);
sum += qian[0] * tianshu;
a += chexing[0];
sumrenshu += renshu[0];
zaike += chexing[0];
}
if (b == 2) {
System.out.println("车型:" + chexing[1] + " 价钱为:" + qian[1]
+ " 载人:" + renshu[1] + "人");
sum += qian[1] * tianshu;
a += chexing[1];
sumrenshu += renshu[1];
zaike += chexing[1];
}
if (b == 3) {
System.out.println("车型:" + chexing[2] + " 价钱为:" + qian[2]
+ " 载货:" + dunwei[0] + "吨");
sum += qian[2] * tianshu;
a += chexing[2];
totalzaihuiliang += dunwei[0];
zaihuo += chexing[2];
}
if (b == 4) {
System.out.println("车型:" + chexing[3] + " 价钱为:" + qian[3]
+ " 载人:" + renshu[2] + "人");
sum += qian[3] * tianshu;
a += chexing[3];
sumrenshu += renshu[2];
zaike += chexing[3];
}
if (b == 5) {
System.out.println("车型:" + chexing[4] + " 价钱为:" + qian[4]
+ " 载货:" + dunwei[1] + "吨");
sum += qian[4] * tianshu;
a += chexing[4];
totalzaihuiliang += dunwei[1];
zaihuo += chexing[4];
}
if (b == 6) {
System.out.println("车型:" + chexing[5] + " 价钱为:" + qian[5]
+ " 载货:" + dunwei[2] + "吨");
sum += qian[5] * tianshu;
a += chexing[5];
totalzaihuiliang += dunwei[2];
zaihuo += chexing[5];
}
}
}
// System.out.println("总的钱为:"+sum);
}
public void tianshu() {
Scanner in3 = new Scanner(System.in);
tianshu = in3.nextInt();
}
public void shuliang() {
Scanner in1 = new Scanner(System.in);
c = in1.nextInt();
for (int i = 1; i < c + 1; i++) {
System.out.println("请输入第" + i + "辆车的序号");
xuanche();
}
}
public void totalprice() {
System.out.println("总的钱为:" + sum + "元");
}
public void totalchexing() {
System.out.println("总的车型为:" + a);
}
public void zaikeliang() {
System.out.println("总载客量为:" + sumrenshu + "人");
}
public void zaihuoliang() {
System.out.println("总载货量为:" + totalzaihuiliang + "吨");
}
public void zaike() {
System.out.println("车型为:" + zaike);
}
public void zaihuo() {
System.out.println("车型为:" + zaihuo);
}
}