package Sbzuce;
public abstract class car{
public int a[][];
public String d[][];
}//其实,不需要抽象类来着,但是,要是不写,太少了
package Sbzuce;
import java.util.*;
public class fengmian extends car{
public static void main(String[] args) {
int[][] a= {{10,200},{10,300},{20,300}};
String[]d= {"小车a","小车b","大车"};
Scanner scan = new Scanner(System.in);
System.out.println("你是否要租车?"+"\n1、是\n"+"2、否");
int A=scan.nextInt();
if(A==1) {
System.out.print("id"+"\t"+"车名"+"\t"+"载客量(人)"+"价格(元)");
for(int i=0;i<3;i++) {
int m=i+1;
System.out.print("\n"+m+"\t"+d[i]+"\t");
for (int j=0;j<2;j++) {
System.out.print(a[i][j]+"\t"+"\t");}
}
int B =scan.nextInt();
System.out.println("请输入数量");
int C =scan.nextInt();
for(int i=0;i<3;i++)
{
if(B==i+1) {
int c1=C*a[i][1];
int c2=C*a[i][1];
System.out.println("名称为:"+d[i]+"\t"+"载人为:"+c2+"价格:"+c1);
}
}
}
else{System.out.print("babai");
}
}}
为什么要用二维数组,我觉得用对象和属性来表示车的车名,载客量和价格会比较好