CodePudding user response:
Package com.ruoyi.com mon;
Import the Java. Math. BigDecimal;
import java.util.Scanner;
Public class Demo {
//the biggest age
Private static final Integer MAX_AGE=80;
Private static final Integer AGE=20;
Public static void main (String arg []) {
Scanner sc=new Scanner (System. In);
System. The out. Println (" please enter the annual salary: ");
//salary unit is the yuan, integer,
BigDecimal salary=new BigDecimal (sc) nextInt ());
System. The out. Println (" please input prices: ");
//price unit is RMB, integer,
BigDecimal housePrices=new BigDecimal (sc) nextInt ());
//deposit
BigDecimal deposit=new BigDecimal (salary. The toString ());
For (int I=20; I & lt;=80; I++) {
System. Out. Println (I + "wages, age:" + salary + + deposit ", deposit: "+", house prices: "+ housePrices);
If (deposit.com pareTo (housePrices) & gt;=0) {
System. Out.println ((I) + ", can buy a house!" );
return;
} else {
Salary=salary. Multiply (new BigDecimal (1). The add (new BigDecimal (" 0.08 "))). Divide (new BigDecimal (1), 2, BigDecimal. ROUND_HALF_UP);
Deposit=deposit. The add (salary);
HousePrices=housePrices. Multiply (new BigDecimal (1). The add (new BigDecimal (" 0.1 "))). Divide (new BigDecimal (1), 2, BigDecimal. ROUND_HALF_UP);
}
}
System. Out.println (" you die!" );
}
}
CodePudding user response:
The