预览加载中,请您耐心等待几秒...
1/4
2/4
3/4
4/4

在线预览结束,喜欢就下载吧,查找使用更方便

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

实现租车汽车租赁系统,不同车型日租金情况如表7-1所示; 车型及日期轿车客车车型别克Gl8宝马750别克凯越<=19座>19座日租金(元/天)7506005008001200 编程实现计算不同车型不同天数的租赁费用。 packagezuche; publicabstractclassMotoVehicle{ privateStringno; privateStringbrand; int[]fee={750,600,500,800,1200}; publicMotoVehicle(){} publicMotoVehicle(Stringno,Stringbrand){ this.no=no;this.brand=brand; } publicStringgetNo(){ returnno; } publicStringgetBrand(){ returnbrand; } publicvoidsetBrand(Stringbrand){ this.brand=brand; } publicvoidsetNo(Stringno){ this.no=no; } publicvoidprintInfo(){ System.out.println("***汽车的信息***"+"\n汽车品牌"+this.brand+"\n车牌号"+this.no); } publicabstractvoidcalRent(intdays); } packagezuche; publicclassCarextendsMotoVehicle{ privateStringtype;//String[]type1={"别克凯越","宝马730","别克凯越","中小客车(19座以内)","大型客车(19座以上)"}; publicCar(){} publicCar(Stringno,Stringbrand,Stringtype){ super(no,brand); this.type=type; } publicStringgetType(){ returntype; } publicvoidsetType(Stringtype){ this.type=type; } publicvoidprintInfo(){ //super.printInfo();//调用父类的构造方法,子类不能直接继承父类的构造方法; System.out.println("***汽车的信息***"+"\n汽车品牌"+getBrand()+"\n型号"+this.type+"\n车牌号"+getNo()); } publicvoidcalRent(intdays){ intrent=0; if("宝马".equals(getBrand())) { rent=days*600;} elseif("别克".equals(getBrand())&&"gl8".equals(this.type)) {rent=days*750;} else {rent=days*500;} System.out.println("你的租车费用为"+rent+"元"); } } packagezuche; publicclassBusextendsMotoVehicle{ privateintseatCount; publicBus(){} publicintgetSeatCount(){ returnseatCount; } publicvoidsetSeatCount(intseatCount){ this.seatCount=seatCount; } publicvoidprintInfo(){ System.out.println("***汽车的信息***"+"\n车牌号"+getNo()+"\n客车座位数"+this.seatCount+"座"); } publicvoidcalRent(intdays){ intrent=0; if(seatCount<=19){rent=days*800; }else{ rent=days*1200; } System.out.println("你的租车费用为"+rent+"元"); } } packagezuche; importjava.util.Scanner; publicclassTestRent{ publicstaticvoidmain(String[]args){ Scannerinput=newScanner(System.in); //intcarType; Stringanswer; intday=0; Ca