第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

參考了其余小伙伴的,然后花了6,7個小時做出來了,雖然時間久,但是我真的很開心

public class CarSystem {//這是一個父類

public String name;

public int rent;

public int people;

public int goods;

@Override

public String toString(){

return "車名"+name+" "+"租金"+rent+" "+"載人"+people+" "+"載物"+goods;

}

}


public class PassangerCar extends CarSystem {//這是能載人的子類

public PassangerCar(String name,int rent,int people){

this.name = name;

this.people = people;

this.rent = rent;

}

}

public class Trunk extends CarSystem {//這是載物的子類

public Trunk(String name,int rent,int goods){

this.name = name;

this.goods = goods;

this.rent = rent;

}

}

public class PickUp extends CarSystem {//這是能載人能載物的子類

public PickUp(String name,int rent,int people,int goods){

this.name = name;

this.people = people;

this.rent = rent;

}

}

import java.util.Scanner;//這是程序的入口

public class Initail {

public static void main(String[] args) {

CarSystem c[]={new PassangerCar("奧迪A4", 500, 4),

new PassangerCar("馬自達6", 600, 4),

new PickUp("皮卡雪6", 450, 2, 4),

new PassangerCar("金龍", 800, 20),

new Trunk("松花江", 400, 4),

new Trunk("依維柯", 1000, 20)};

System.out.println("歡迎來到大大租車");

System.out.println("租車請按1走錯請按0");

Scanner s=new Scanner(System.in);

int p=s.nextInt();

if(p==1){

System.out.println("您可以租車的類型及其價目表:");

for(int i=0;i<c.length;i++){

System.out.println("第"+(i+1)+"種車"+c[i]);

}

}else if(p==0){

System.out.println("謝謝點擊");

}else{

System.out.println("輸入錯誤");

}

System.out.println("請輸入你要租的車的數(shù)量:");

Scanner input=new Scanner(System.in);

int[] a=new int[200] ?;

for(int i=0;i<c.length;i++){

System.out.println("請輸入您對第"+(i+1)+"種車需要的數(shù)量:");

int q=input.nextInt();

a[i]=q*c[i].rent;

}

System.out.println("請輸入租車天數(shù):");

int t=input.nextInt();

System.out.println("您的賬單:");

for(int i=0;i<c.length;i++){

System.out.println("租第"+(i+1)+"種車的費用是"+a[i]*t);

}

int sum=0;

for(int i=0;i<c.length;i++){

sum+=a[i]*t;

}

System.out.println("共計"+sum);

}

}


正在回答

5 回答

挺好的,,,很厲害的

1 回復 有任何疑惑可以回復我~
#1

木木和呆呆 提問者

非常感謝!
2016-05-14 回復 有任何疑惑可以回復我~

載人能載物的子類少了個 this.goods=goods;

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

for(int i=0;i<c.length;i++){

System.out.println("請輸入您對第"+(i+1)+"種車需要的數(shù)量:");

int q=input.nextInt();

a[i]=q*c[i].rent;

}

哥哥? 這個? a[i]=q*c[i].rent;? 是什么意思啊

??

}

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

你主函數(shù)里的問題是car是一個數(shù)組,需要a[i]=num*car[i].rent 你先試試看,行不行,再回復我

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

為什么我會出現(xiàn)這些問題呢?能不能幫忙解答下?

573706c50001d14905000255.jpg

573706c500017bee05000399.jpg

我就是參考你的代碼進行編寫的,可是出現(xiàn)了這兩類問題,小白不知道怎么改正;

0 回復 有任何疑惑可以回復我~
#1

愛學習的小灰

你的子類里面寫錯了吧
2016-06-20 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

參考了其余小伙伴的,然后花了6,7個小時做出來了,雖然時間久,但是我真的很開心

我要回答 關注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號