Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package TestJan;
- import java.text.DecimalFormat;
- import java.util.Scanner;
- public class Triangle {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- DecimalFormat decimalFormat = new DecimalFormat("0.#");
- double a = Double.parseDouble(scanner.nextLine());
- double b = Double.parseDouble(scanner.nextLine());
- double c = Double.parseDouble(scanner.nextLine());
- boolean checkIsTriangle = !((a < b + c) && (b < a + c) && (c < a + b));
- boolean checkIsScalene = (a != b && b != c && a != c);
- boolean checkIsIsosceles = ((a == b || b == c || a == c) && (a != b || b != c || a != c));
- boolean checkIsEquilateral = (a == b && b == c && a == c);
- if (checkIsTriangle) {
- System.out.println("There is no triangle with sides " + decimalFormat.format(a) + ", " + decimalFormat.format(b) + " and " + decimalFormat.format(c)+".");
- } else if (checkIsScalene) {
- System.out.println("Triangle with sides " + decimalFormat.format(a) + ", " + decimalFormat.format(b) + " and " + decimalFormat.format(c) + " is scalene.");
- } else if (checkIsIsosceles) {
- System.out.println("Triangle with sides " + decimalFormat.format(a) + ", " + decimalFormat.format(b) + " and " + decimalFormat.format(c) + " is isosceles.");
- } else if (checkIsEquilateral) {
- System.out.println("Triangle with sides " + decimalFormat.format(a) + ", " + decimalFormat.format(b) + " and " + decimalFormat.format(c) + " is equilateral.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement