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]
3 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]3 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
Selma writes the following four answers in her Computer Science examination.
REY [17]

Answer:

Interrupts.

Explanation:

A software can be defined as a set of executable instructions (codes) or collection of data that is used typically to instruct a computer on how to perform a specific task and solve a particular problem.

The four (4) input-output (I/O) software layers includes the following;

I. User level software: it provides user programs with a simple user interface to perform input and output functions.

II. Device drivers: it controls the input-output (I/O) devices that are connected to a computer system through a wired or wireless connection.

III. Device-independent OS software: it allows for uniform interfacing and buffering for device drivers.

IV. Interrupt drivers (handlers): it is responsible for handling interruptions that occur while using a software on a computer system.

An interrupt is a signal from a program or device connected to a computer and it's typically designed to instruct the operating system (OS) that an event has occurred and requires an attention such as stopping its current activities or processes.

In conclusion, the computer term that Selma is describing is interrupts.

3 0
3 years ago
Read 2 more answers
What is presentation
Gelneren [198K]
To present something infront of a crowd
5 0
3 years ago
Read 2 more answers
Computer science practical on VB.NET. program 1. program to find the square of a number. write the code achieve it​
Korvikt [17]

Answer:

Module Program

   Sub Main()

       Dim num As Integer

       num = 4

       Console.WriteLine("The square of " & num & " is " & num * num)

       Console.ReadKey()

   End Sub

End Module

Explanation:

Very similar to the other program you posted.

6 0
3 years ago
A unit of measurement that describe the rate that electricity flows through a wire is an
Savatey [412]
AMPERE - a unit of measure for the flow of the current in a circut
8 0
3 years ago
Which one of the following statements most fully describes the general capabilities of desktop publishing software?
OleMash [197]
The answer is B.
<span> desktop publishing program must be able to take text and graphics from a number of sources and allow these elements to be arranged on a page. 
The main purpose of a destkop publishing program is to aid user in creating documents using its page layout so it could generate printable media with higher quality compared to the one that is handmade.</span>
7 0
3 years ago
Other questions:
  • Philip is thinking about customizing his motorcycle. A paint job, saddlebags, and a radio would cost $600. His motorcycle is old
    15·2 answers
  • Jennifer's company currently uses Windows Active Directory to provide centralized authentication, authorization, and accounting
    14·1 answer
  • What is not true of credit scores?
    11·1 answer
  • To answer the research question "How am I going to find the information I need on the tople?" the best thing Georgia should
    15·1 answer
  • How have productivity programs improved the professional lives of people? (check all that apply)
    8·2 answers
  • Describe the components of a CPU--the CU, ALU, and Cache--and explain how they interact to make the CPU function.
    13·1 answer
  • Write a program that simulates flipping a coin to make decisions. The input is how many decisions are needed, and the output is
    14·1 answer
  • Select the correct answer from each drop-down menu.
    7·1 answer
  • Can someone help me get spotify premium
    7·2 answers
  • What is are the most efficient ways to make a slide presentation?
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!