package com.carsystem;import java.util.*;public class RentSystem {Car cars[] ={new PassengerCar("奧迪A4",500,4),new PassengerCar("馬自達(dá)",400,4),new Pickup("皮卡雪",450,2,4),new PassengerCar("金龍",800,20),new GoodsVan("松花江",400,4),new GoodsVan("依維柯",1000,20)};?int count;?int day;?int money;Car[] rent = new Car[100];static Scanner input = new Scanner(System.in);public static void main(String[] args) {RentSystem hello = new RentSystem();System.out.println("歡迎使用答答租車系統(tǒng):");System.out.println("您是否要租車:1 是 0 否");int select = input.nextInt();if(select==0){ input.close(); System.exit(-1); }System.out.println("您可租車的類型及其價(jià)目表:"); System.out.println("序號(hào) 汽車名稱 租金 容量");System.out.println("1. 奧迪A4 500/天 載人:4人"); System.out.println("2. 馬自達(dá) 400/天 載人:4人"); System.out.println("3. 皮卡雪 450/天 載人:4人,載貨:2噸"); System.out.println("4. 金龍 800/天 載人:20人"); System.out.println("5. 松花江 500/天 載貨:4噸"); System.out.println("6. 依維柯 1000/天 載貨:20噸"); System.out.println("請(qǐng)輸入您要租車額數(shù)量:");int rentNum = input.nextInt();for(int i=0;i<rentNum;i++){?System.out.println("您要租的第"+(i+1)+"輛車的序號(hào)");?int a = input.nextInt();while(a<1||a>6){System.out.println("您輸入的數(shù)據(jù)有問(wèn)題,請(qǐng)重新輸入");int b = input.nextInt();a=b; }int p = hello.cars[a-1].price;hello.money +=p;hello.rent[i] = hello.cars[a-1];}System.out.println("您要租車的天數(shù):");int c = input.nextInt();hello.money*=c;System.out.println("您的租車賬單");int loadAmount =0;int passengerAmount =0;for(int i=0;i<rentNum;i++){System.out.print(hello.rent[i].name+" "); loadAmount+=hello.rent[i].load;passengerAmount+=hello.rent[i].pNum;}?System.out.println();System.out.println("您的租車載人數(shù)量"+passengerAmount+"人"); System.out.println("您的租車載貨量"+loadAmount+"噸"); System.out.println("您的租車總費(fèi)用:"+hello.money); } }
從輸入您要租車額數(shù)量開始就有好多問(wèn)題不懂的,求指導(dǎo)!可以加微信指導(dǎo)指導(dǎo)我嗎
慕萊塢1282154
2017-10-10 11:05:43