简易购房商贷月供计算器
public class Calculate {
public double lone;
public int yearchoice;
public int yc;
public double interestRate;
public double monthlyPayment;
public void Calculate(double lone,int yearchoice) {
if (yearchoice == 1) {
yc = 36;
interestRate = 0.0603;
}
if (yearchoice == 2) {
yc = 60;
interestRate = 0.0612;
}
if (yearchoice == 3) {
yc = 240;
interestRate = 0.0639;
}
monthlyPayment = (lone + (lone * interestRate)) / yc;
}
public double getMonthlyPayment() {
return monthlyPayment;
}
}
import java.util.Scanner;
public class HomeBuyersAgentCalculator {
public static void main(String[] args) {
Calculate a = new Calculate();
System.out.print("请输入贷款金额:");
Scanner input = new Scanner(System.in);
a.lone = input.nextDouble();
System.out.println("请选择贷款年限:");
a.yearchoice = input.nextInt();
a.Calculate(a.lone, a.yearchoice);
System.out.println("***月供为:" + a.getMonthlyPayment());
}
}
判断三角形
public class JudgeTheTriangle {
public int a;
public int b;
public int c;
public boolean determineWhetherItIsATriangle(int a,int b,int c){
if (a + b > c && a + c > b&&b + c > a){
return true;
} else {
System.out.println("不是三角形!");
return false;
}
}
public void judgeWhatKindOfTriangle(int a,int b,int c){
if (a == b&&b == c){
System.out.println("三角形是等边三角形");
} else if ((a * a) == ((b * b) +(c * c))||(b * b) == ((a * a) +(c * c))||(c * c) == ((b * b) +(a * a))){
System.out.println("三角形为直角三角形");
} else if ((a * a) > ((b * b) +(c * c))||(b * b) > ((a * a) +(c * c))||(c * c) > ((b * b) +(a * a))){
System.out.println("三角形为钝角三角形");
} else {
System.out.println("三角形为锐角三角形");
}
}
}
import java.util.Scanner;
public class Triangle {
public static void main(String[] args) {
boolean i = true;
while (i){
Scanner input = new Scanner(System.in);
JudgeTheTriangle first = new JudgeTheTriangle();
System.out.println("请输入第一条边");
first.a = input.nextInt();
System.out.println("请输入第二条边");
first.b = input.nextInt();
System.out.println("请输入第三条边");
first.c = input.nextInt();
if (first.determineWhetherItIsATriangle(first.a, first.b, first.c)){
first.judgeWhatKindOfTriangle(first.a, first.b, first.c);
}
System.out.println("继续吗?(Y/N)");
if (input.next().equals("N")) {
i = false;
}
}
}
}