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
Select the correct answer from each drop-down menu. Which IF formulas are valid? _____ and _____ are valid IF formulas.
Lyrx [107]

Answer:

=IF(D3>50; E3; F3) AND =IF(A1>60;"Pass";"Fail")

Explanation:

An IF structure is built following this pattern:

IF(TEST;IFTRUE;IFFALSE)

These are the only options in the given drop-down menus what comply with this pattern.  All others are not following this pattern.

The computer will do the test and if the result is true will apply the IFTRUE value, otherwise will apply the IFFALSE value.

4 0
3 years ago
2.Use loops to create a 4X6 matrix in which the value of each element is two times its row number minus three times its column n
DiKsa [7]

Answer:

for(i=0; i<4; i++)

{

      for(j=0;j<6;j++)

      {

               A[ i ][ j ] = 2* i - 3*j;

      }

}

Explanation:

In this loop for each i = 0,1,2,3 we fill the the corresponding column values. and then move to next i value i.e. row.

3 0
3 years ago
10) ________ objects control the flow of the application. A) Boundary B) Utility C) Control D) All of the above
Cerrena [4.2K]

There are different kinds of applications.  Control objects control the flow of the application.

<h3>What works the flow of control in a program?</h3>

In computer, control flow or flow of control is known to be a type of an order function calls, instructions, and statements.

They are known to be used in the execution or in an evaluation when a specific program is running. Note that a lot of programming languages have the control flow statements, that helps to know the section of code is run in a program at any given time.

Learn more about application from

brainly.com/question/23275071

7 0
2 years ago
What is the definition of physical fitness?
Bond [772]
The answer is A:the body’s ability to be efficient during movement.
5 0
3 years ago
Read 2 more answers
Where could identity theft access your personal information?
riadik2000 [5.3K]
From hacking into public websites where you pay and stuff, or put in a fake official window to lure out your private info.
6 0
3 years ago
Read 2 more answers
Other questions:
  • Which of these browsers was the first widely adopted?
    12·1 answer
  • [Submit on zyLabs] Please write a function with one input, a matrix, and one output, a matrix of the same size. The output matri
    10·1 answer
  • What can u access various sites on
    12·1 answer
  • Question 1 :George, a user, is having trouble connecting to network resources, including shared folders on the local network and
    7·1 answer
  • In a car crash, wearing a seat belt __________________.
    5·2 answers
  • Which of these files, when included in a program, will provide user assistance?
    5·2 answers
  • Which of the following is true of information systems?
    15·1 answer
  • Which statement describes how to insert the IF, COUNTIF, or SUM function into a cell?
    11·1 answer
  • In 5-10 sentences, describe the procedure for responding to an e-mail message.
    5·1 answer
  • Is a device used to test the network connection.
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!