Day08作业

Day08作业

第2题

在这里插入图片描述

在这里插入图片描述

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题

在这里插入图片描述

在这里插入图片描述

 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;
	    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值