Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package at.ac.fhstp.eidherr;
- import java.util.Scanner;
- import java.lang.Math;
- public class Bsp5 {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- double a,b,c,a2,b2,c2;
- System.out.println("Enter length of side a: ");
- a=input.nextFloat();
- System.out.println("Enter length of side b: ");
- b=input.nextFloat();
- System.out.println("Enter length of side c: ");
- c=input.nextFloat();
- // a=Math.sqrt(12.5);
- // b=Math.sqrt(12.5);
- // c=5;
- a2=Math.pow(a, 2);
- b2=Math.pow(b, 2);
- c2=Math.pow(c, 2);
- a2=roundDown(a2);
- b2=roundDown(b2);
- c2=roundDown(c2);
- if(c>=a+b || a>=b+c || b>=a+c) {
- System.out.println("its not a triangle at all");
- System.exit(0);
- }
- else if(a==b && a==c) {
- System.out.println("its a same sided triangle");
- }
- else if(a2+b2==c2 && a==b) {
- System.out.println("its a right angled same sided triangle");
- }
- else if(a==b & a!=c) {
- System.out.println("its a same winged triangle");
- }
- else if((Math.pow(a, 2)+Math.pow(b, 2))==Math.pow(c, 2)) {
- System.out.println("its a right angled triangle");
- }
- else {
- System.out.println("its a regular triangle");
- }
- int u = (int) (a+b+c), s=u/2;
- double bigA = Math.sqrt((double)s*(s-a)*(s-b)*(s-c));
- System.out.printf("The circumverence of the triangle is %dcm, the surface area is %.2fcm² ", u, bigA);
- input.close();
- }
- public static double roundDown(double d) {
- return ((long)(d* 1e12))/1e12;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement