Question

In: Computer Science

(JAVA) Write an application that reads three nonzero values entered by the user and determines and...

(JAVA) Write an application that reads three nonzero values entered by the user and determines and prints whether they could represent the sides of a triangle. Enter three sizes, separated by spaces(decimals values are acceptable): 4.5·5.5·3.5 A triangle could measure 4.50, 5.50, by 3.50.

Solutions

Expert Solution

import java.util.Scanner;

public class TriangleCheck {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        double a, b, c;

        System.out.println("Enter three sizes, separated by spaces(decimals values are acceptable): ");
        a = scanner.nextDouble();
        b = scanner.nextDouble();
        c = scanner.nextDouble();

        if (a + b <= c || a + c <= b || b + c <= a){
            System.out.printf("A triangle could NOT measure %.2f, %.2f, by %.2f.",a,b,c);
        }
        else{
            System.out.printf("A triangle could measure %.2f, %.2f, by %.2f.",a,b,c);
        }
        System.out.println();
    }
}


Related Solutions

Instructions: Create a Java program that reads a string entered by the user and then determines...
Instructions: Create a Java program that reads a string entered by the user and then determines and prints how many of each lowercase vowel (a, e, i, o, and u) appear in the entire string. Have a separate counter for each vowel. Also, count and print the number of non-vowel characters. Example: User enters: "This house is beautiful." a: 1 e: 2 i: 3 o: 1 u: 2 non-vowel:10
Q6: (Sides of a Right Triangle) Write a function that reads three nonzero integers and determines...
Q6: (Sides of a Right Triangle) Write a function that reads three nonzero integers and determines whether they are the sides of a right-angled triangle. The function should take three integer arguments and return 1 (true) if the arguments comprise a right-angled triangle, and 0 (false) otherwise. Use this function in a program that inputs a series of sets of integers. Hint: a^2+b^2=C^2 Codes in C please.s
Q6: (Sides of a Right Triangle) Write a function that reads three nonzero integers and determines...
Q6: (Sides of a Right Triangle) Write a function that reads three nonzero integers and determines whether they are the sides of a right-angled triangle. The function should take three integer arguments and return 1 (true) if the arguments comprise a right-angled triangle, and 0 (false) otherwise. Use this function in a program that inputs a series of sets of integers. Hint: a^2+b^2=C^2
Write a Java application that prompts the user for an age. If the age entered is...
Write a Java application that prompts the user for an age. If the age entered is greater or equal to 65, display the statement "Age is greater than or equal to 65"; otherwise display the message "Age is less than 65". If the age entered is less than 18; display the statement "This person is a minor"; otherwise display the message "This person can legally vote. Do not create a class for this application. The code can be created in...
How to write a java application that reads an integer, then determines and display whether it's...
How to write a java application that reads an integer, then determines and display whether it's odd or even. Use the remainder operator.
In Java write an application that calculates total retail values for 5 different shoes entered by...
In Java write an application that calculates total retail values for 5 different shoes entered by the user. Shoe 1 $15.50 Shoe 2 $27.30 Shoe 3 $34.50 Shoe 4 $42.11 Shoe 5 $54.25 Application must read shoe number and quantity sold for each product stdin, compute the total value of that sale, and add the value of that sale to a grand total for that shoe. After all data has been entered, display the total value of each of the...
Write a Java program (name it LargestOccurenceCount) that reads from the user positive non-zero integer values,...
Write a Java program (name it LargestOccurenceCount) that reads from the user positive non-zero integer values, finds the largest value, and counts it occurrences. Assume that the input ends with number 0 (as sentinel value to stop the sentinel loop). The program should ignore any negative input and should continue to run. Hint: to remember/save entered (good) values, you can concatenate them into a string (separated by spaces) that you can output later on. Sample runs showing input prompts and...
programing language JAVA: Design and implement an application that reads a sentence from the user, then...
programing language JAVA: Design and implement an application that reads a sentence from the user, then counts all the vowels(a, e, i, o, u) in the entire sentence, and prints the number of vowels in the sentence. vowels may be upercase
Write a JAVA program that reads in a string from standard input and determines the following:...
Write a JAVA program that reads in a string from standard input and determines the following: - How many vowels are in the string (FOR THE PURPOSE OF THIS PROGRAM 'Y' is NOT considered a vowel)? - How many upper case characters are in the string? - How many digits are in the string? - How many white space characters are in the string? - Modify the program to indicate which vowel occurs the most. In the case of a...
Write a Java application that inputs an unknown number of employees and determines and displays the...
Write a Java application that inputs an unknown number of employees and determines and displays the gross pay for each employ. The company pays straight time for the first 40 hours worked by each employee (hours times rate), and straight time plus time-and-a-half for all hours worked in excess of 40 hours. Input the number of hours worked and hourly rate for each of the employees, then determine and display the employee’s gross pay. At the end of the program,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT