Question

In: Computer Science

Write a program whose inputs are three integers, and whose outputs are the largest of the three values and the smallest of the three values.

 in Coral Simulator 

Write a program whose inputs are three integers, and whose outputs are the largest of the three values and the smallest of the three values. If the input is 7 15 3, the output is:

largest: 15
smallest: 3

Your program should define and call two functions:

Function LargestNumber(integer num1, integer num2, integer num3) returns integer largestNum
Function SmallestNumber(integer num1, integer num2, integer num3) returns integer smallestNum

The function LargestNumber should return the largest number of the three input values. The function SmallestNumber should return the smallest number of the three input values.

Solutions

Expert Solution

Code to Copy:

Function LargestNumber(integer num1, integer num2, integer num3) returns integer largestNum

   // Define a function LargestNumber() to find largest among 3

   // numbers. It accepts three numbers and returns largest number.

  

   if num1>num2 and num1>num3

      largestNum=num1

   elseif num3>num1 and num3>num2

      largestNum=num3

   else

      largestNum=num2

Function SmallestNumber(integer num1, integer num2, integer num3) returns integer smallestNum

   // Define a function SmallestNumber() to find largest among 3

   // numbers. It accepts three numbers and returns smallest number.

  

   if num1

      smallestNum=num1

   elseif num3

      smallestNum=num3

   else

      smallestNum=num2

Function Main() returns nothing

   // Define a Main() function.

  

   // Define three integer variables.

   integer num1

   integer num2

   integer num3

  

   //Prompt the user to get 3 integer numbers.

   num1=Get next input

   num2=Get next input

   num3=Get next input

  

   // Display the largest number and call LargestNumber()

  

   Put "largest: " to output

   Put LargestNumber(num1,num2,num3) to output

  

   // Display the smallest number and call smallestNumber()

  

   Put "smallest: " to output

   Put SmallestNumber(num1,num2,num3) to output


Related Solutions

Write a program whose inputs are three integers, and whose output is the smallest of the...
Write a program whose inputs are three integers, and whose output is the smallest of the three values
Write a program whose inputs are three integers, and whose output is the smallest of the...
Write a program whose inputs are three integers, and whose output is the smallest of the three values. Use else-if selection and comparative operators such as '<=' or '>=' to evaluate the number that is the smallest value. If one or more values are the same and the lowest value your program should be able to report the lowest value correctly. Don't forget to first scanf in the users input. Ex: If the input is: 7 15 3 the output...
Code in C Write a program whose inputs are three integers, and whose outputs are the...
Code in C Write a program whose inputs are three integers, and whose outputs are the largest of the three values and the smallest of the three values. Ex: If the input is: 7 15 3 the output is: largest: 15 smallest: 3 Your program must define and call the following two functions. The LargestNumber function should return the largest number of the three input values. The SmallestNumber function should return the smallest number of the three input values. int...
in coral write a program whose inputs are three integers, and whose output is the largest...
in coral write a program whose inputs are three integers, and whose output is the largest of the three values. Ex: If the input is 7 15 3, the output is: 15
CORAL LANGUAGE ONLY Write a program whose inputs are three integers, and whose outputs are the...
CORAL LANGUAGE ONLY Write a program whose inputs are three integers, and whose outputs are the largest of the three values and the smallest of the three values. If the input is 7 15 3, the output is: largest: 15 smallest: 3 Your program should define and call two functions: Function LargestNumber(integer num1, integer num2, integer num3) returns integer largestNum Function SmallestNumber(integer num1, integer num2, integer num3) returns integer smallestNum The function LargestNumber should return the largest number of the...
Write a program whose inputs are two integers, and whose output is the smallest of the...
Write a program whose inputs are two integers, and whose output is the smallest of the two values. Ex: If the input is: 7 15 output is: 7 passed through command line *in python
Write a program Write a program whose inputs are three integers, and whose output is the...
Write a program Write a program whose inputs are three integers, and whose output is the smallest of the three values. Ex: If the input is: 7 15 3 the output is: 3 C++ please
Program must be in Python Write a program in Python whose inputs are three integers, and...
Program must be in Python Write a program in Python whose inputs are three integers, and whose output is the smallest of the three values. Input is 7 15 3
Write a program that inputs three integers in the range [1..13] that represent a hand of...
Write a program that inputs three integers in the range [1..13] that represent a hand of three cards. Your program should output an English evaluation of the hand. In the output, cards will be described as follows: - 2–10 are described by the words for their numeric values: two, three, etc. - 1 is called an ace, 11 is called a jack, 12 is called a queen, and 13 is called a king. The evaluation of a hand is based...
Write a C++ program that inputs three integers in the range [1..13] that represent a hand...
Write a C++ program that inputs three integers in the range [1..13] that represent a hand of three cards. Your program should output an English evaluation of the hand. In the output, cards will be described as follows: - 2–10 are described by the words for their numeric values: two, three, etc. - 1 is called an ace, 11 is called a jack, 12 is called a queen, and 13 is called a king. The evaluation of a hand is...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT