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
Which of the following devices are least likely to deny a connection inline when an attack is detected? (select 2)
user100 [1]

Answer: Option (A) & (D) are correct.

Layer 2 switch is commonly referred to as a type of network or device switch that tends to work on data link layer and use MAC addresses in order to determine the route through which the frames are forwarded.

An IDS known as intrusion detection system is commonly referred to as a device or application that controls a network for malevolent activity and its policy violations.

7 0
3 years ago
How has the global marketplace used emerging technologies to expand businesses
madam [21]

Answer:

Information Technology (IT) has revolutionized the way organizations conduct business by enabling small and medium businesses to level the playing field with larger organizations. Small businesses use an array of technology based on everything from computer server stations to portable mobile devices to expand competitive advantages in the global economic marketplace and marketing environment. So, small & medium business organizations owners are considering implementing information technology (IT) in their planning process for streamlined integration. Thus, this process is leading to future business expansion locally as well as globally. This decision allows proprietors to create smooth business operations using the most effective information technology available. On the other hand, the Internet has further linked the overseas suppliers of goods and services and their buyers. During the e-commerce era, internet traffic is increasing day by day, and e-commerce business is in the hyper growth stage. Information technology tremendously helps to boost the expansion of the current and future of marketing environment; communication technology became faster than ever. Though, globalization creates a little challenge for multinational companies to share resources and knowledge across a number of businesses inside and outside the country. Outsourcing and freelancer ease this challenge because multinational companies recruit talent freelancers and outsource their projects to the highly expert vendors and then the works are done through the team of people very effectively and efficiently.

Explanation:

6 0
2 years ago
14. Emelia is very concerned about safety and has conducted a study to determine how many bike helmets were replaced at each loc
damaskus [11]

Answer:

Explanation:

Known Variables A = max Daily Rentals

X = Damaged helmets %

lets find the formula to calculate Helmets per location :taking 1st row as an example.

412 = B - (B*13/100)

412 = (100B-13B)/100

412*100 = 87B

B= 412*100/87

Hence, the generic formula becomes : B= A*100/(100-X)

Applying the same formula for each row and then using ROUND function of excel to round off the digits

=ROUND(number,digits) where number is the number you would like to round off and the digits is the number of decimal digits for it to round off. Since we want natural numbers in our example, we will be using digits as 0.

Explanation:

See attached pictures also.

5 0
3 years ago
Read 2 more answers
You can sort data in a table or_____?<br><br><br> A. Report<br> B. Form<br> C. Field<br> D. Record
Mazyrski [523]

Answer:I believe its form

Explanation:

7 0
3 years ago
Read 2 more answers
After turning volume all the way up on your computer speaker you still can’t hear any sound. What should be done next
wariber [46]

Answer:

check to see if you have headphones or snything plug in to it that might take the sound if not try restarting your computer, or your speakers are broken with water damage or over use

Explanation:

4 0
3 years ago
Other questions:
  • Which of the following is a goal of paraphrasing​
    12·1 answer
  • What is the function of the command prompt?
    8·1 answer
  • How does form get its power natural gas
    14·1 answer
  • I have a problem with Instagram.
    11·1 answer
  • Someone say crackhead
    15·2 answers
  • How is the OR (||) logical operator used?<br> PLS HURRY
    11·1 answer
  • What is the binary for O?​
    5·2 answers
  • Determine of population size​
    11·1 answer
  • Explain the term creating in word processing​
    12·1 answer
  • Give an example of how loops are used in programming Kturtle​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!