java大神,这题怎么做得啊!谢谢了(^~^)详细点
发布网友
发布时间:2024-04-20 14:58
我来回答
共1个回答
热心网友
时间:2024-11-02 09:49
import java.util.Scanner;
public class test {
private double money = 0;
private double repayment = 0;
public double loan(double loan,int yearchoice){
switch (yearchoice) {
case 1:
money = loan*0.0603;
repayment = (money+loan)/36;
break;
case 2:
money = loan*0.0612;
repayment = (money+loan)/60;
break;
case 3:
money = loan*0.0639;
repayment = (money+loan)/240;
break;
}
return repayment;
}
public static void main(String[] args) {
test t = new test();
Scanner sc = new Scanner(System.in);
System.out.println("请输入贷款金额:");
double loan = sc.nextDouble();
System.out.println("请输入贷款年限:1.3年(36个月) 2.5年(60个月) 3.20年(240个月)");
int yearchoice = sc.nextInt();
System.out.println("月供为:"+t.loan(loan, yearchoice));
}
}