|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
package cars;
public class Car {
String vehicleld;
String brand;
String type;
static int perRent1;
Car(String vehicleld,String brand,String type,int perRent){
this.vehicleld=vehicleld;
this.brand=brand;
this.type=type;
perRent=perRent1;
}
public String getVehicleld() {
return vehicleld;
}
public void setVehicleld(String vehicleld) {
this.vehicleld = vehicleld;
}
public String getBrand() {
return brand;
}
public void setBrand(String brand) {
this.brand = brand;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public static int getPerRent() {
return perRent1;
}
public static void setPerRent(int perRent) {
perRent = perRent1;
}
public static float calRent(int days) {
float money;
money = getPerRent()*days;
if(days>7)
{money*=0.9;}
else if(days>30)
{money*=0.8;}
else if(days>150)
{money*=0.7;}
return money;
}
}
package cars;
import java.util.Scanner;
class RentMgrSys {
public static void main(String[] args) {
System.out.println("1.宝马 2.别克");
Scanner sc = new Scanner(System.in);
System.out.print("请选择你要租赁的轿车品牌:");
int brandNum = sc.nextInt();{
if(brandNum==2)
System.out.println("1.林荫大道 2.GL8");
else if(brandNum==1)
System.out.println("1.550i 2.X6)");}
System.out.println("请选择你要租赁的汽车类型:");
int typeNum = sc.nextInt();
System.out.print("请选择您要租赁的天数:");
int days = sc.nextInt();{
if(typeNum==1&&brandNum==1){//600
Car.setPerRent(600);
System.out.println("分配给您的汽车牌号是:京CNY3284");
}
else if(typeNum==1&&brandNum==2){//300
Car.setPerRent(300);
System.out.println("分配给您的汽车牌号是:京NT37465");
}
else if(typeNum==2&&brandNum==1){//800
Car.setPerRent(800);
System.out.println("分配给您的汽车牌号是:京NY28588");
}
else if(typeNum==2&&brandNum==2){//600
Car.setPerRent(600);
System.out.println("分配给您的汽车牌号是:京NT96968");
}
System.out.println("您需要支付的租赁费用是:"+Car.calRent(days)+"元。");}
}}
运行结果
1.宝马 2.别克
请选择你要租赁的轿车品牌:1
1.550i 2.X6)
请选择你要租赁的汽车类型:
1
请选择您要租赁的天数:1
分配给您的汽车牌号是:京CNY3284
您需要支付的租赁费用是:0.0元。
//反正怎么都是0.0
perRent=perRent1;这句代码是不是问题代码?
|
|