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
An Oven Is Just A Spicy Refrigerator? Yes Or No??
Marianna [84]

Answer:

No

Explanation:They both have different actions

3 0
3 years ago
Read 2 more answers
Which is the another name of automatic sequence control calculator​
Alla [95]

Answer:

IBM Automatic Sequence Controlled Calculator (ASCC)

3 0
3 years ago
What is the advantage of video conferecing
Svet_ta [14]

some advantages of video conferencing include:

• you can talk no matter how far you are from the person

•you won’t have to go somewhere to talk

•there is no cost if you need to travel far

7 0
3 years ago
Read 2 more answers
What is the name of an instruction that interrupts a program being executed and requests a service from the operating system
tresset_1 [31]
“Interrupt” is what I think the answer is
7 0
2 years ago
Do you think Google has an unfair advantage as a social media marketing platform? Explain.
Bond [772]
In some aspects, yes but these have recently been outweighed with the ad boycott youtube has not to mention google plus wasn't the most popular, to begin with, but in an overall sense yes as the name google is more often used than Facebook or twitter
3 0
3 years ago
Read 2 more answers
Other questions:
  • A url consists of a ____, a domain name, sometimes the path to a specific web page or location in a web page, and the web page n
    11·1 answer
  • Can you please answer these questions for me: Is it illegal to copyright? What does it mean to get copyrighted? What are example
    12·2 answers
  • Evaluating how current, credible, and unbiased a source is ensures:
    7·1 answer
  • The domain name service (dns is a distributed database that allows users to communicate with each other computers by:
    7·1 answer
  • Blank is a type of drag and drop code to help beginner
    14·1 answer
  • Which of the following statements is true about a file stream?
    5·1 answer
  • The variable most_recent_novel is associated with a dictionary that maps the names of novelists to their most recently published
    12·1 answer
  • If you have configured your prompt so that it does not show your working directory, you can use the ____ command to verify in wh
    15·1 answer
  • What is the difference between autofocus and autocomplete
    8·1 answer
  • The variable points stores data that the user has input. what is the data type of this variable?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!