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
frozen [14]
4 years ago
12

Integers and booleans. Write a program RightTriangle that takes three int command-line arguments and determines whether they con

stitute the side lengths of some right triangle. right triangle The following two conditions are necessary and sufficient: Each integer must be positive. The sum of the squares of two of the integers must equal the square of the third integer.
Computers and Technology
1 answer:
icang [17]4 years ago
4 0

Answer:

<em>The programming language is not stated;</em>

<em>I'll answer using C++</em>

#include<iostream>

#include<cmath>

using namespace std;

int main()

{

int side1, side2, side3;

cout<<"Enter the three sides of the triangle: "<<endl;

cin>>side1>>side2>>side3;

if(side1<=0 || side2 <= 0 || side3 <= 0) {

 cout<<"Invalid Inputs";

}

else {

 if(abs(pow(side1,2) - (pow(side2,2) + pow(side3, 2)))<0.001) {

  cout<<"Right Angled";

 }

 else if(abs(pow(side2,2) - (pow(side1,2) + pow(side3, 2)))<0.001) {

  cout<<"Right Angled";

 }

 else if(abs(pow(side3,2) - (pow(side2,2) + pow(side1, 2)))<0.001) {

  cout<<"Right Angled";

 }

 else {

  cout<<"Not Right Angled";

 }

}

return 0;

}

Explanation:

The following line declares the three variables

int side1, side2, side3;

The next line prompts user for input of the three sides

cout<<"Enter the three sides of the triangle: "<<endl;

The next line gets user input

cin>>side1>>side2>>side3;

The following if condition checks if any of user input is negative or 0

<em> if(side1<=0 || side2 <= 0 || side3 <= 0) { </em>

<em>  cout<<"Invalid Inputs"; </em>

<em> } </em>

If otherwise

else {

The following if condition assumes that side1 is the largest and test using Pythagoras Theorem

<em>if(abs(pow(side1,2) - (pow(side2,2) + pow(side3, 2)))<0.001) { </em>

<em>   cout<<"Right Angled"; </em>

<em>  } </em>

The following if condition assumes that side2 is the largest and test using Pythagoras Theorem

<em>  else if(abs(pow(side2,2) - (pow(side1,2) + pow(side3, 2)))<0.001) { </em>

<em>   cout<<"Right Angled"; </em>

<em>  } </em>

The following if condition assumes that side3 is the largest and test using Pythagoras Theorem

<em>  else if(abs(pow(side3,2) - (pow(side2,2) + pow(side1, 2)))<0.001) { </em>

<em>   cout<<"Right Angled"; </em>

<em>  } </em>

If none of the above conditions is true, then the triangle is not a right angles triangle

<em>  else { </em>

<em>   cout<<"Not Right Angled"; </em>

<em>  } </em>

}

return 0;

Download cpp
You might be interested in
Select the correct answer.
Naddika [18.5K]

Answer:

E

Explanation:

4 0
3 years ago
By incorporating video games into classwork, teachers would help students become more confident decision makers.
dangina [55]

teachers would help students become more confident decision makers.

7 0
4 years ago
Read 2 more answers
.What particular skills does a team leader need in addition to the other skills needed by any team member. (choose all that appl
omeli [17]

Answer:

encourage and support team members

always keep a vision of the “big picture”

communicate frequently with team members

Explanation:

As a team leader, this is important to motivate and encourage team members to move on are especially needed during the hard time to face some challenges or solving some problems.

Besides, a vision of big picture from the team leader will assure the entire team that they are moving in a right direction to achieve a bigger goal despite they are facing a number of challenges/obstacle.

A team work need frequent communication to minimize misunderstanding and to ensure the job allocation and coordination running smooth as expected. A team leader plays the vital role to be proactive in communication with members to make sure every job arrangement are monitored and on track.

6 0
3 years ago
Which of the following statements is true about mobile devices and procedures?
Zarrin [17]

Answer:

No

Explanation:

No

5 0
3 years ago
If you're using an existing PowerPoint presentation that will receive new slides based on a Word outline, select the
oksian1 [2.3K]

ITS D BECAUSE ADDING NEW SLIDES TO AN EXISTING POWERPOINT YOU WILL NEED TO GO TO THE LAST SLIDE TO ADD MORE SLIDES TO IT.

7 0
4 years ago
Other questions:
  • Write an application that allows a user to enter any number of student quiz scores until the user enters 99. If the score entere
    15·1 answer
  • _____ is the network protocol that deals with the routing of packets through interconnected networks to the final destination.
    9·1 answer
  • Which of the following refers to a combination of hardware and software that ensures only authorized individuals gain entry into
    11·1 answer
  • Data mining is defined as: a)Separating data and programs such that each can be changed without changing the other b)Allowing ma
    5·1 answer
  • What is the purpose of a Program Epic?
    7·2 answers
  • Ted knows that macros can be helpful to him in his work with Excel spreadsheets,but he also knows they have their hazards,so he
    15·1 answer
  • E) Point out the errors( if any) and correct them:-
    14·1 answer
  • Free pass if you want it.
    12·2 answers
  • 2. The<br>is the main and usually largest data storage hardware device in a computer​
    9·1 answer
  • A large retailer is asking each customer at checkout for their zip code. if the zip code is the only recorded variable, what is
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!