Home > Back-end >  This subject, I myself for a long time also do not come out, have a great god can help?
This subject, I myself for a long time also do not come out, have a great god can help?

Time:10-03

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
_ datang ssangyong's reply: 1/f, reference
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!" );
}


}

(?????? Omega?? )??

CodePudding user response:

Dizzy, I said I, I just wanted to say when house prices is greater than the salary you can judge, can be directly printed Forget it, the calculation is a waste, the topic of itself has a problem,

CodePudding user response:

When the wage is more than prices, you can buy a house in the first year, so there is no need to calculate,

CodePudding user response:

refer to 6th floor qq_39936465 response:
when the wage is more than prices, you can buy a house in the first year, so there is no need to calculate,


Salary is cumulative, prices do not accumulate,,, you salary for 10 w, 20 w, house prices you can buy a house for 3 years,,
Can be performed under the above code I try,
  • Related