Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a program for the Little Man Computer ( LMC ) that takes in three numbers and checks to see if they are a Pythagorean

Create a program for the Little Man Computer (LMC) that takes in three numbers and checks to see if they are a Pythagorean Triple (PT). A PT is a set of three positive integers such that
a2+ b2= c2
Your program should take in 3 numbers and then calculate if they are a PT.
The numbers that are entered may be in any order. Any of the following would be a valid PT
3,4,53,5,4
4,3,54,5,3
5,3,45,4,3
As the program is running, each time that you have completed the calculation of a squared number, the squared number it should be output. The squared numbers can be output in any order. They do not have to be output in the order entered or in sorted order.
The program should output 0 if the numbers are a PT.
The program should output a 1 if the numbers are not a PT.
Each time the program is executed, it will output 4 values: the three squared values and a 0 or 1 to indicate that is or is not a PT.
The program should perform two error checks on at least one input value:
1) The input number should be greater than or equal to the smallest value for part of a PT
2) The number should be less than or equal to a value that would cause LMC to overflow when squaring the value
3) You will need to determine the largest and smallest input values to allow.
4) If either edit fails, output 2 and stop the program

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions