yan15430632
2015-07-20 14:55
package project02; public class Car { public void CarNum(){ int CarNumber=1; String CarName="夏利"; int Money1=500; System.out.println(CarNumber+"\t"+CarName+"\t"+Money1+"/天"); } public void CarNum2(){ int CarNumber=2; String CarName="奥迪"; int Money2=600; System.out.println(CarNumber+"\t"+CarName+"\t"+Money2+"/天"); } public void CarNum3(){ int CarNumber=3; String CarName="悍马"; int Money3=700; System.out.println(CarNumber+"\t"+CarName+"\t"+Money3+"/天"); } public int Money=500; public int Money2=600; public int Money3=700; public String Name="夏利"; public String Name2="奥迪"; public String Name3="悍马"; }
package project02; public class Car2 { public void CarNum(){ int CarNumber=4; String CarName="宝马"; int Money1=800; System.out.println(CarNumber+"\t"+CarName+"\t"+Money1+"/天"); } public void CarNum2(){ int CarNumber=5; String CarName="金龙"; int Money2=900; System.out.println(CarNumber+"\t"+CarName+"\t"+Money2+"/天"); } public void CarNum3(){ int CarNumber=6; String CarName="法拉利"; int Money3=1000; System.out.println(CarNumber+"\t"+CarName+"\t"+Money3+"/天"); } public int Money=800; public int Money2=900; public int Money3=1000; public String Name="宝马"; public String Name2="金龙"; public String Name3="法拉利"; }
package project02; import java.util.*; public class Initail { public static void main(String[] args) { Scanner Sca=new Scanner(System.in); System.out.println("\t\t****欢迎使用租车系统****"); System.out.println("请问是否租车?"+"(租车请输入1,不租请输入2)"); int i=Sca.nextInt(); if(i==1){ System.out.println("您可租用车辆信息如下:"); System.out.println("汽车序号"+"\t汽车名称"+"\t价钱"); Car car=new Car(); Car2 car2=new Car2(); car.CarNum(); car.CarNum2(); car.CarNum3(); car2.CarNum(); car2.CarNum2(); car2.CarNum3(); System.out.print("请输入您要租车的序号:"); int Num=Sca.nextInt(); System.out.print("请输入您要租车的天数:"); int Num2=Sca.nextInt(); System.out.println("\t**您租用的车辆信息为**"); if(Num==1){ System.out.println("您租用的车为:"+car.Name+"\t"+"您租车的天数为:"+Num2+"天"); } if(Num==2){ System.out.println("您租用的车为:"+car.Name2+"\t"+"您租车的天数为:"+Num2+"天"); } if(Num==3){ System.out.println("您租用的车为:"+car.Name3+"\t"+"您租车的天数为:"+Num2+"天"); } if(Num==4){ System.out.println("您租用的车为:"+car2.Name+"\t"+"您租车的天数为:"+Num2+"天"); } if(Num==5){ System.out.println("您租用的车为:"+car2.Name2+"\t"+"您租车的天数为:"+Num2+"天"); } if(Num==6){ System.out.println("您租用的车为:"+car2.Name3+"\t"+"您租车的天数为:"+Num2+"天"); } if(Num==1){ System.out.println("您租车的费用为"+car.Money*Num2); } if(Num==2){ System.out.println("您租车的费用为"+car.Money2*Num2); } if(Num==3){ System.out.println("您租车的费用为"+car.Money3*Num2); } if(Num==4){ System.out.println("您租车的费用为"+car2.Money*Num2); } if(Num==5){ System.out.println("您租车的费用为"+car2.Money2*Num2); } if(Num==6){ System.out.println("您租车的费用为"+car2.Money3*Num2); } System.out.println("\t**感谢您的使用**"); } else{ System.out.println("感谢您的使用"); } } }
我用的也是比较基础的,一起加油吧
Java入门第二季 升级版
530562 学习 · 6091 问题
相似问题