1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Nadya [2.5K]
3 years ago
7

Write a Java program that prompts the user to enter integer values for the sides of a triangle and then displays the values and

the type of triangle they represent. If the user enters values that do not make a valid triangle, or if any values are not greater than zero, your program should display the values entered as well the following error message: The values entered do not make a valid triangle.
Computers and Technology
1 answer:
satela [25.4K]3 years ago
7 0

Answer:

import java.util.Scanner;

public class triangle {

       public static void main (String [] args) {

           int sideOne, sideTwo, sideThree;

           Scanner in = new Scanner (System.in);

           System.out.println("Enter the first side of the triangle");

           sideOne = in.nextInt();

           System.out.println("Enter the secon side of the triangle");

           sideTwo = in.nextInt();

           System.out.println("Enter the third side of the triangle");

           sideThree = in.nextInt();

           if ( sideOne<=0||sideTwo<=0|| sideThree<=0){

               System.out.println(" The Values enter are "+sideOne+ "," +sideThree+ ","+sideThree+ " These values don't make a valid triangle");

           }

           else if ((sideOne + sideTwo> sideThree) || (sideOne+sideThree > sideTwo) || (sideThree+sideTwo > sideOne))

           {

               System.out.println ("The triangle is Valid");

           }

           else {

               System.out.println(" The Values enter are "+sideOne+ "," +sideTwo+ ","+sideThree+ " These values don't make a valid triangle");

           }

       }

Explanation:

for a Triangle to be Valid one of the three sides of the triangle must greater than the other two sides.  The code above enforces this condition using an if statement in combination with the Or Operator

The following conditions where enforced

side one, side two and side three != 0

Side One + Side Three > Side Two

Side Three + Side Two> Side One

Side Two + Side One > Side Three

You might be interested in
Can some one help please
quester [9]

Answer:

I think its screenplay

Explanation:

Firstly, the question starts with an a so it can't be b. And format can't be repeated. Which leaves us with screenplay.

Hope this helps.

8 0
1 year ago
You are going to write a program for Computer test which will read 10 multiple choice questions from a file, order them randomly
sweet-ann [11.9K]

Answer:

Code is too large , i attached a source file below and also a text file from where i get Questions

Explanation:

6 0
3 years ago
Draw the 2-3 tree that results when you insert the keys E A S Y Q U T I O N in that order into an initially empty tree
mr_godi [17]

Answer:

If its any easy question, answer it yourself.

Explanation:

:)

6 0
2 years ago
Arman, a friend of your dad, has a computer running Windows 7 and wants to perform an upgrade. He has only 3GB of RAM in his com
torisob [31]

Answer:

Low memory?

So to fix the problem you could add more memory to the machine.

Explanation:

8 0
3 years ago
Special keys that allow you to use the computer to perform specific functions
Pavel [41]

Answer:

Examples are Ctrl, Alt, Fn, Alt Gr, Shift, Caps Lock, Tab, Scroll Lock, Num lock, Esc, Windows Key, Backspace, Enter...

8 0
3 years ago
Other questions:
  • If you purchase a software suite for personal use, you can install the software how many times on how many different machines?
    6·1 answer
  • Assume that the variables gpa, deansList and studentName, have been declared and initialized . Write a statement that both adds
    6·1 answer
  • What keyboard shortcut keys selects cell A1
    12·1 answer
  • One of the original forms of viruses, is usually stored on some form of removable media. When the removable media is connected t
    9·1 answer
  • Write a program that asks the user for three strings. Then, print out whether the first string concatenated to the second string
    8·1 answer
  • Give sally sue specific suggestions on how she can improve her powerpoint skills.
    6·1 answer
  • ________ uses the signals transmitted over the phone to access the database, retrieve account information and input data. Group
    11·1 answer
  • A group of Automation Anywhere Enterprise users are required to automate bots for a customer change requirement. The users find
    10·1 answer
  • Please help
    11·1 answer
  • Write a program that uses a dictionary to store students birthdays. Your program should ask the user what their name is, and loo
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!