验证中...
gistfile1.txt
Raw Copy
package com.hello;
import java.math.*;
import java.util.Scanner;
/*
* 用class里面不能加syste.out.print();
* 然后用public void 又不能继承,test失败。
* 日期2019.5.18
*/
public class test {
double a;//成员变量 边a
double b;//成员变量 边b
double angel;//成员变量 夹角angel
public void zhouchang(double a,double b,double angel) {
//double hudu=angel*(Math.PI/180);//转换成弧度
double cosx=Math.cos(angel*(Math.PI/180));//cos值
double c=Math.sqrt(a*a+b*b-2*a*b*cosx);//最后一条边
System.out.println("三角形的周长是:"+String.format("%.1f", (a+b+c)));
}
public void mianji(double a,double b,double angel){
//double hudu=angel*(Math.PI/180);//转换成弧度
double cosx=Math.cos(angel*(Math.PI/180));//cos值
double c=Math.sqrt(a*a+b*b-2*a*b*cosx);
double p=(a+b+c)/2;
double s=Math.sqrt(p*(p-a)*(p-b)*(p-c));
System.out.println("三角形面积的是:"+String.format("%.1f", s));
}
public static void main(String[] args) {
Scanner aScanner=new Scanner(System.in);
System.out.println("请输入一边的长:");
double A=aScanner.nextDouble();
Scanner bScanner=new Scanner(System.in);
System.out.println("请输入一边的长:");
double B=bScanner.nextDouble();
Scanner angerScanner=new Scanner(System.in);
System.out.println("请输入夹角:");
double an=angerScanner.nextDouble();
test zhouchangTest=new test();
zhouchangTest.zhouchang(A, B, an);
zhouchangTest.mianji(A, B, an);
}
}

Comment list( 0 )

You need to Sign in for post a comment

Help Search

Gitee_sixth 5th_float_left_close