手记

达达租车,写了好久,学的感觉还是不会用,写了个最简单的

package DaDaZuChe;
import java.util.Scanner;

public class ShiXian {

public static void main(String[] args) {
    // TODO Auto-generated method stub

    String[] cheming={"宝马","奔驰","奥迪"};
    int[][] shuju={{4,100,500},{4,80,400},{2,50,1000}};

System.out.println("车型  装载人数  载货量  价格");    
System.out.println("宝马   4     100  500");
System.out.println("奔驰   4     80   400");
System.out.println("奥迪   2     50   1000");
System.out.println("(宝马代码为1,奔驰代码为2,奥迪代码为3)");

Scanner input=new Scanner(System.in);
System.out.print("请选择车辆类型: ");
int xuanze=input.nextInt();
System.out.print("请选择车辆数量: ");
int shuliang=input.nextInt();

int zongjia =shuliang*shuju[xuanze-1][2];
int zaihuoshuliang=shuliang*shuju[xuanze-1][1];
int zongrenshu=shuliang*shuju[xuanze-1][0];

System.out.println(" 您的租车清单");
System.out.print("租车总金额:"+zongjia+" ");
System.out.print("总人数"+zongrenshu+" ");
System.out.print("载货量"+zaihuoshuliang+" ");

}

}

0人推荐
随时随地看视频
慕课网APP