How to write a Java program that after prompting the user to enter the lengths of sides (3) of a triangle, it prints:
"Enter the lengths of the sides of triangle 1: 6 6 6"
"A triangle with sides of 6,6,6 is equilateral."
import java.util.Scanner; public class TypeOfTriagle { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print("Enter the lengths of the sides of triangle 1: "); int a = scanner.nextInt(); int b = scanner.nextInt(); int c = scanner.nextInt(); String result; if (a == b && b == c) result = "equilateral"; else if (a == b || b == c) result = "isosceles"; else result = "scalene"; System.out.println("A triangle with sides of 6,6,6 is "+result+"."); } }
Enter the lengths of the sides of triangle 1: 6 6 6 A triangle with sides of 6,6,6 is equilateral.
How to write a Java program that after prompting the user to enter the lengths of...
2. Write a program that prompts a user to enter the lengths of sides and angles for the two triangles described below. The program should calculate the length of the side of the triangle indicated below. Print the two answers to 3 decimal places onto the console screen Triangle 1 Read in the value of the angle, alpha, and the length, a, of the side indicated in the picture below. Calculate the length of the hypotenuse, c, of this right...
//////// ONLY JAVA **** //////// ONLY JAVA **** 5. In a right triangle, the square of the length of one side is equal to the sum of the squares of the lengths of the other two sides. Write a program that prompts the user to enter the lengths of three sides of a triangle and then outputs a message indicating whether the triangle is a right triangle. (Have the user enter the lengths 3, 4, and 5).
1) Write a Python program that prompts the user to enter the current month name and prints the season for that month. Hint: If the user enters March, the output should be "Spring"; if the user enters June, the output should be "Summer". 2 )Write a Python program using the recursive/loop structure to print out an equilateral triangle below (double spacing and one space between any two adjacent asterisks in the same row). * * * * *...
Java Please - Design and implement a class Triangle. A constructor should accept the lengths of a triangle’s 3 sides (as integers) and verify that the sum of any 2 sides is greater than the 3rd(i.e., that the 3 sides satisfy the triangle inequality). The constructor should mark the triangle as valid or invalid; do not throw an exception. Provide get and set methods for the 3 sides, and recheck for validity in the set methods. Provide a toString method...
write a java program that prompts a user to enter two different numbers, divide the first number by second and prints the result
Design a Java program that asks the user to enter an integer number n and then generates an array of that many random points (x, y) with x- and y-coordinates in the range between 0 and 100. After this the program must ask the user to enter two diagonal points (x_1, y_1) and (x_2, y_2) of a rectangle with sides parallel to the coordinate axis (see the image below, where possible pairs of diagonal points are shown in red color)....
Write a java program that asks the user to enter 2 integers, obtains them from the user, determines if they are even or odd numbers and prints their sum, product, difference, and quotient (Division).
Write the java program: A right triangle can have sides whose lengths are all integers. The set of three integer values for the length of the sides of a triangle is called a Pythagorean triple. The length of the three sides must satisfy the relationship that the sum of the squares of the sides is equal to the square of the hypotenuse. Write a Java application that prompts the user for an integer that represents the largest side value and...
JAVA Programming scenario: write a program that will prompt a user for 10 legendary people/characters. After the entries are complete the program will display all 10 characters information. requirements: Create a user-defined class with the fields below: - First - Last - Nickname - Role - Origin Create a main-source that will use the user-defined class and do the prompting. Create get/set methods in your user-defined class and methods in the main-source.
Write a Java program which asks the user to enter an integer x. This program prints the remainder of x when it is divided by 3. Example Pl ea s e e n t e r an i n t e g e r : 3 remainde r=0 Pl ea s e e n t e r an i n t e g e r : 17 remainde r=2