为了账号安全,请及时绑定邮箱和手机立即绑定

​用写C的写法写的。。。。

package com.imooc;
import java.util.Scanner;
public class Initial {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		System.out.println("欢迎使用嗒嗒租车系统:"+"\n"+"您是否要租车:1是 0否");
		Scanner scan1= new Scanner(System.in);
		int a=scan1.nextInt();
		if(a==0){
			System.out.println("如果下次需要租车请光临嗒嗒租车");
		}else{
			System.out.println("您可租车的类型及其价目表:"+"\n"+
		"序号    汽车名称       租金              容量"+"\n"+
		"1.  奥迪A4  500元/天      载人: 4人"+"\n"+
		"2.  马自达6  400元/天     载人: 4人"+"\n"+
		"3.  皮卡雪6  450元/天     载人: 4人  载货:2吨"+"\n"+
		"4.  金龙             800元/天     载人: 20人"+"\n"+
		"5.  松花江         400元/天     载货: 4吨"+"\n"+
		"6.  依维柯         1000元/天  载货: 20吨"+"\n"+
		"请输入您要租车的数量:");			
		}
		Scanner scan2= new Scanner(System.in);
		int b=scan2.nextInt();
		int c[]=new int [10];
		for(int i=1,j=0;i<=b;i++,j++){
			System.out.println("请输入第"+i+"辆车的序号:");
			Scanner sc= new Scanner(System.in);
			c[j]=sc.nextInt();
		}
		System.out.println("请输入租车天数:");
		Scanner scan3= new Scanner(System.in);
		int days=scan3.nextInt();
		System.out.println("*****可载人的车有:");
		int passenger=0;
		double capacity=0;
		int  rentMoney=0;
		for(int i=0; i<c.length; i++){
			if(c[i]==1){
				System.out.print("奥迪A4  ");
				passenger+=4;
				rentMoney+=500*days;
			}
			else if (c[i]==2){
				System.out.print("马自达6  ");
				passenger+=4;
				rentMoney+=400*days;
			}
			else if (c[i]==3){
				System.out.print("皮卡雪6  ");
				passenger+=4;
				capacity+=4.0;
				rentMoney+=450*days;
			}
			else if (c[i]==4){
				System.out.print("金龙  ");
				passenger+=20;
				rentMoney+=800*days;
			}
			else if (c[i]==5){
					System.out.print("松花江  ");
					passenger+=4;
					rentMoney+=400*days;
			}
			else {
				capacity+=20.0;
				rentMoney+=1000*days;
			}
		}
		System.out.println("共载人:"+passenger+"\n"+"载货的车有:");
		for(int i=0; i<c.length; i++){
			if (c[i]==3){
				System.out.print("皮卡雪6  ");
			}
			else if(c[i]==6){
				System.out.print("依维柯    ");
			}
		}
		System.out.println("共载货:"+capacity);
		System.out.println("****出租车总价格:"+rentMoney);
	}
}


正在回答

1 回答

还是不会,还有,这是JAVA

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
Java入门第二季 升级版
  • 参与学习       530714    人
  • 解答问题       6091    个

课程升级!以终为始告别枯燥,在开发和重构中体会Java面向对象编程的奥妙

进入课程

​用写C的写法写的。。。。

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信