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

这个才是需要找错的。。。。

这个才是需要找错的。。。。

java2016817 2016-08-20 22:16:37
帮忙找错。感激不尽。 package cn.com.didizuchexitong; import java.util.Scanner; public class Test { public static void main(String[] args) { System.out.println("欢迎使用答答租车系统:您是否要租车:1.是 0.否"); Scanner input = new Scanner(System.in); int choice = input.nextInt(); while(true){ if(choice!=0 && choice!=1){ System.out.println("您输入有误,请重新输入。"); }else{ break; } choice = input.nextInt(); } if(choice==1){ System.out.println("您可租车的类型及其价目表"); System.out.println("序号" + "\t" + "汽车名称" + "\t\t" + "租金" + "\t\t" + "容量"); Vehicle[] v = {new Car("奥迪A4",500,4),new Car("马自达6",400,4),new PickUp("皮卡雪6",450,4,2), new Car("金龙",800,20),new Truck("松花江",400,4),new Truck("依维柯",1000,20)}; for (int i = 0 ; i<v.length; i++) { System.out.print(i+1); v[i].dayIn(); } }else{ System.exit(0); } System.out.println("请输入您要租车的数量:"); int num = input.nextInt(); Vehicle[] v1 = new Vehicle[num]; for(int i = 0 ; i<num; i++){ System.out.println("请输入第" + (i + 1) + "辆车的序号:"); int number = input.nextInt(); v1[i] = v1[number-1]; } System.out.println("请输入租车天数:"); int day = input.nextInt(); System.out.println("您的账单:"); int sum = 0; int zairenshu = 0; int zaihuoshu = 0; for(int j = 0 ; j<v1.length; j++){ if(v1[j] instanceof Car){ Car c = (Car)v1[j]; sum = sum + c.getMoney()*day; zairenshu = zairenshu + c.getCarload(); }if(v1[j] instanceof Truck){ Truck t = (Truck)v1[j]; sum = sum + t.getMoney()*day; zaihuoshu = zaihuoshu + t.getFreight(); }if(v1[j] instanceof PickUp){ PickUp pu = (PickUp)v1[j]; sum = sum + pu.getMoney()*day; zairenshu = zairenshu + pu.getCarload(); zaihuoshu = zaihuoshu + pu.getFreight(); } } System.out.println("可载人的车:"); for(int k = 0 ; k<v1.length; k++){ if(v1[k] instanceof Car || v1[k] instanceof PickUp){ System.out.println(v1[k].getName() +"\t"); } } System.out.println("总载人数:" + zairenshu + "人"); System.out.println("可载货的车:"); for(int n = 0 ; n<v1.length; n++){ if(v1[n] instanceof Truck || v1[n] instanceof PickUp){ System.out.println(v1[n].getName() +"\t"); } } System.out.println("总载货数:" + zaihuoshu + "吨"); System.out.println("总租金为:" + sum + "元。"); } } import java.util.Scanner; public class Test { public static void main(String[] args) { System.out.println("欢迎使用答答租车系统:您是否要租车:1.是 0.否"); Scanner input = new Scanner(System.in); int choice = input.nextInt(); while(true){ if(choice!=0 && choice!=1){ System.out.println("您输入有误,请重新输入。"); }else{ break; } choice = input.nextInt(); } if(choice==1){ System.out.println("您可租车的类型及其价目表"); System.out.println("序号" + "\t" + "汽车名称" + "\t\t" + "租金" + "\t\t" + "容量"); Vehicle[] v = {new Car("奥迪A4",500,4),new Car("马自达6",400,4),new PickUp("皮卡雪6",450,4,2), new Car("金龙",800,20),new Truck("松花江",400,4),new Truck("依维柯",1000,20)}; for (int i = 0 ; i<v.length; i++) { System.out.print(i+1); v[i].dayIn(); } }else{ System.exit(0); } System.out.println("请输入您要租车的数量:"); int num = input.nextInt(); Vehicle[] v1 = new Vehicle[num]; for(int i = 0 ; i<num; i++){ System.out.println("请输入第" + (i + 1) + "辆车的序号:"); int number = input.nextInt(); v1[i] = v1[number-1]; } System.out.println("请输入租车天数:"); int day = input.nextInt(); System.out.println("您的账单:"); int sum = 0; int zairenshu = 0; int zaihuoshu = 0; for(int j = 0 ; j<v1.length; j++){ if(v1[j] instanceof Car){ Car c = (Car)v1[j]; sum = sum + c.getMoney()*day; zairenshu = zairenshu + c.getCarload(); }if(v1[j] instanceof Truck){ Truck t = (Truck)v1[j]; sum = sum + t.getMoney()*day; zaihuoshu = zaihuoshu + t.getFreight(); }if(v1[j] instanceof PickUp){ PickUp pu = (PickUp)v1[j]; sum = sum + pu.getMoney()*day; zairenshu = zairenshu + pu.getCarload(); zaihuoshu = zaihuoshu + pu.getFreight(); } } System.out.println("可载人的车:"); for(int k = 0 ; k<v1.length; k++){ if(v1[k] instanceof Car || v1[k] instanceof PickUp){ System.out.println(v1[k].getName() +"\t"); } } System.out.println("总载人数:" + zairenshu + "人"); System.out.println("可载货的车:"); for(int n = 0 ; n<v1.length; n++){ if(v1[n] instanceof Truck || v1[n] instanceof PickUp){ System.out.println(v1[n].getName() +"\t"); } } System.out.println("总载货数:" + zaihuoshu + "吨"); System.out.println("总租金为:" + sum + "元。"); } }
查看完整描述

5 回答

?
汁十一

TA贡献5条经验 获得超2个赞

你这样  让人看的很焦着啊


查看完整回答
反对 回复 2016-09-26
?
大咪

TA贡献785条经验 获得超332个赞

同志,你复制代码的时候可以选择代码行,然后复制进去,这样在网页上是以代码形式显示,便于大家帮你差错啊……

查看完整回答
反对 回复 2016-09-01
  • java2016817
    java2016817
    用手机登陆的。还不太熟悉。不好意思
  • 大咪
    大咪
    哦哦好的吧,手机那是不太方便哈哈哈
?
悟二空

TA贡献10条经验 获得超29个赞

问题描述框左上角不是有选择代码语言么,下次可以放到那里面,提供缩进和样式化方便查看,你这个代码贴的太乱了没法看

查看完整回答
反对 回复 2016-08-31
?
Bossen

TA贡献13条经验 获得超4个赞

写的乱七八糟,无从看起

查看完整回答
反对 回复 2016-08-21
  • java2016817
    java2016817
    复制的原因。不知道怎么在这个上面排版 囧
  • 5 回答
  • 0 关注
  • 1755 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信