谁能帮我用java按要求做。

来源:百度知道 编辑:UC知道 时间:2024/05/25 08:10:12
The video game machines at your local arcade output coupons according to how well you play the game.
You can redeem 10 coupons for a candy bar or 3 coupons for a gumball.You prefer candy bars to gumballs.Write a program that defines a variable initially assigned to the number of coupons you win. Next,the program should output how many candy bars and gumballs you can get if you spend all of your coupons on candy bars first,and any remaining coupons on gumballs.

class RedeemPolicy{
public int couponNum = 0;
public static int candyPrice = 10;
public static int gumballPrice = 3;
public RedeemPolict(int couponNum){
this.couponNum = couponNum;
}
public void redeem(){
System.out.println("I need "+(couponNum/candyPrice)+" candy bars.");
System.out.println("and I still need "+((couponNum%candyPrice)/gumballPrice)+" gumballs")
}
}