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
The physical devices that make up a computer system are called
LUCKY_DIMON [66]
The question is broad and vague, but I would say hardware.
3 0
4 years ago
You locate a web page that includes "edu" in the address, along with other words and symbols. the page is simple—a plain backgro
stich3 [128]
No, just because it is an edu address doesn't mean it is a good source. Avoid websites with minimal content or effort to the page they are most likely fake. <span />
7 0
4 years ago
This career involves answering questions about computer parts and trouble shooting broken computers? Video game designer, comput
adelina 88 [10]

Computer retail sales associate is my best guess. :)

3 0
3 years ago
Which tab provide text formatting features
kirill [66]

Answer:

Home tab

Explanation:

Assuming that this question is based on providing text formatting features in Microsoft Word, this feature is found on the Home tab in the Font group or the Font dialog box. Some of these formatting features include underline style, colour, strikethrough, superscript, and subscript.

4 0
4 years ago
1.<br> The correct way to use a seat belt is
Nesterboy [21]

Answer:

4 steps

Explanation:

Step 1: Pull belt across body

Sit in any of your vehicle's seats and secure the three-point harness in its buckle by pulling it across your body.

If the seatbelt is too short, consider an aftermarket restraint and extender. Make sure they meet federal safety standards and are installed professionally.

Step 2: Adjust lower belt

Adjust the lower belt snuggly across your lap and pelvis area – never your stomach.

Pregnant women should wear the lap belt below their belly, not on or above it.

Step 3: Adjust shoulder belt

Adjust the shoulder belt to fit comfortably across the collarbone and chest. It should never rub on your neck or face. Never put the shoulder belt behind your back or under your arm.

Step 4: Check before driving

Check that the belt is secure before driving.

4 0
3 years ago
Other questions:
  • What specific information would you need to obtain from an ISP or cloud service provider whose hosting services you wanted to us
    9·1 answer
  • What port does the DarkComet malware listen on?
    15·1 answer
  • Write a c++ function, largestnum, that takes as parameters a double array and its size and returns the index of the last occurre
    14·1 answer
  • PLS ANSWER ASAP!
    9·1 answer
  • Two Smallest (20 points). Write a program TwoSmallest.java that takes a set of double command-line arguments and prints the smal
    7·1 answer
  • Word processing software programs can run on smartphones.<br> True<br> Or <br> False
    6·1 answer
  • What new information, strategies, or techniques have you learned that will increase your technology skills?
    14·1 answer
  • I am in school what should i do i am 15
    5·2 answers
  • How to identify mistakes in a html code??​
    14·1 answer
  • 2. Write the pseudocode to print all multiples of 5 between 10 and 25 (including both<br> 10 and 25)
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!