亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

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

沒有頭緒!各位同學快來探討

沒有頭緒!各位同學快來探討

正在回答

2 回答

package 達達租車;


import java.util.*;

public class Carrental {


public static void main(String[] args) {

// TODO Auto-generated method stub

? ? ? ? Vehicle v=new Vehicle();

? ? ? ??

? ? ? ? Scanner reader=new Scanner(System.in);

? ? ? ? System.out.println("歡迎使用達達租車系統:");

? ? ? ? System.out.println("你是否要租車:1是 ? 0否");

? ? ? ??

? ? ? ? int s=reader.nextInt();

? ? ? ? if(s==1){

? ? ? ? ? ?v.information();

? ? ? ? ? ?System.out.println("請輸入您要租汽車的數量:");

? ? ? ? ? ?int a=reader.nextInt();

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

? ? ? ? ? ?for(int i=0;i<a;i++){

? ? ? ? ? System.out.println("請輸入第"+(i+1)+"輛車的序號:");

? ? ? ? ? b[i]=reader.nextInt();

? ? ? ? ? ?}

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

? ? ? ? ? ?int d=reader.nextInt();

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

? ? ? ? ? ?v.showcar1(a,b);

? ? ? ? ? ?v.showcar2(a,b); ??

? ? ? ? ? ?v.bill(a,d,b);

? ? ? ? }

? ? ? ? else

? ? ? ? System.exit(0);

}

}


package 達達租車;


public class Vehicle {

?String []str={"奧迪A4","馬自達6","皮卡雪6","金龍 ","松花江","依維柯 ?"};

?int []p={500,400,450,800,400,1000};

?

? ? ?void information(){

? ? System.out.println("你可租車的類型及其價格表:");

? ? System.out.println("序號 ? ? ? ? ? ?汽車名稱 ? ? ? ? ? ? ? ?租金 ? ? ? ? ? ? ? ? ? ? ? ?容量 ? ");

? ? System.out.println("1. ? ?奧迪A4 ? ? 500元/天 ? ? ? ? ? 載人:4人 ? ? ?");

? ? System.out.println("2. ? ?馬自達6 ? ? 400元/天 ? ? ? ? ? 載人:4人 ? ? ?");

? ? System.out.println("3. ? ?皮卡雪6 ? ? 450元/天 ? ? ? ? ? 載人:4人 ? 載貨:2噸 ? ");

? ? System.out.println("4. ? ?金龍 ? ? ? ? ? ? ? ? ? ? ? ? 800元/天 ? ? ? ? ? 載人:20人 ? ? ?");

? ? System.out.println("5. ? ?松花江 ? ? ? ? ? ? ? ? ? ? 400元/天 ? ? ? ? ? 載貨:4噸 ? ? ");

? ? System.out.println("6. ? ?依維柯 ? ? ? ? ? ? ? ? ? ? 1000元/天 ? ? ? ?載貨:20噸 ? ? ?");

? ? ?}

? ? ?

? ? ?void showcar1(int a,int b[]){

? ? System.out.println("***可載人的車有:");

? ? ?

? ? for(int i=0;i<a;i++){

? ? if(b[i]<5)

? ? System.out.print(str[b[i]-1]+" ? "); ? ? ?

? ? }

? ? ?

? ? ?}

? ? ?

? ? ?void showcar2(int a,int b[]){

? ? System.out.println("\n***可載人的車有:");

? ? for(int i=0;i<a;i++){

? ? if(b[i]>5||b[i]==3)

? ? System.out.print(str[b[i]-1]+" ? ");

? ?

? ? }

? ? ?}

? ? ? ? ?

? ? ?

? ? ?

? ? ?void bill(int a,int d,int b[]){ ? ?

? ? int m=0;

? ? for(int i=0;i<a;i++){

? ? ? ? m=m+(p[b[i]-1]*d);

? ? }

? ? System.out.println("\n***租車總價格:"+m);

? ? ?

? ??

? ? ?}

}


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

不明覺厲!

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

舉報

0/150
提交
取消

沒有頭緒!各位同學快來探討

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

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號