Day08作业
第2题
![在这里插入图片描述](https://img-blog.csdnimg.cn/20210708103113942.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3d6emd6aG9uZ2d1bw==,size_16,color_FFFFFF,t_70#pic_center)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20210708103144368.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3d6emd6aG9uZ2d1bw==,size_16,color_FFFFFF,t_70#pic_center)
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("请输入贷款金额:");
double money=sc.nextDouble();
System.out.println("请输入贷款年限:1.3年(36个月) 2.5年(60个月) 3.20年(240个月)");
int year=sc.nextInt();
double mon= loan(money,year);
System.out.println("月供为:"+mon);
}
public static double loan(double loan,int yearchoice) {
double money =0;
if(yearchoice ==1) {
money=(loan+loan*0.0603)/36;
}else if(yearchoice==2) {
money=(loan+loan*0.0612)/60;
}else if(yearchoice==3) {
money=(loan+loan*0.0639)/240;
}
return money;
}
如图第3题
![在这里插入图片描述](https://img-blog.csdnimg.cn/20210708103212436.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3d6emd6aG9uZ2d1bw==,size_16,color_FFFFFF,t_70#pic_center)
![在这里插入图片描述](https://img-blog.csdnimg.cn/20210708103225739.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3d6emd6aG9uZ2d1bw==,size_16,color_FFFFFF,t_70#pic_center)
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String yn = "y";
do {
System.out.print("请输入第一条边:");
int one =sc.nextInt();
System.out.print("请输入第二条边:");
int two =sc.nextInt();
System.out.print("请输入第三条边:");
int three =sc.nextInt();
boolean aa =isTriangle(one,two,three);
if(aa) {
String a =shape(one,two,three);
System.out.println("这是一个"+a);
}else {
System.out.println("不是三角形");
}
System.out.print("继续吗?y/n:");
yn=sc.next();
while(!("n".equals(yn)||"y".equals(yn))) {
System.out.print("继续吗?y/n:");
yn=sc.next();
}
}while("y".equals(yn));
System.out.println("谢谢使用!");
}
public static boolean isTriangle(int a,int b,int c) {
boolean flag = false;
if(a+b>c && a+c>b && c+b>a ) {
flag =true;
}
return flag;
}
public static String shape(int a,int b,int c) {
String shape="";
if((a*a+b*b)==c*c ||(a*a+c*c)==b*b || (c*c+b*b)==a*a ){
shape="直角三角形";
}
if((a*a+b*b)<c*c ||(a*a+c*c)<b*b || (c*c+b*b)<a*a ){
shape="钝角三角形";
}else{
shape="锐角三角形";
}
if(a==b && a==c){
shape="等边三角形";
}
return shape;
}