Question

*Using Coral Language* Write a function MaxMagnitude with two integer parameters that returns the largest magnitude...

*Using Coral Language*

Write a function MaxMagnitude with two integer parameters that returns the largest magnitude value.

Ex: If the inputs are 5 7, the function returns 7.

Ex: If the inputs are -8 -2, the function returns -8.

Note: The function does not just return the largest value, which for -8 -2 would be -2. Though not necessary, you may use the absolute value built-in math function: AbsoluteValue

Use the function in a program that gets two integer inputs, and outputs the largest magnitude value.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is the completed code for this problem in Coral language. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. Thanks

Note: Please follow the indentation (spacing) very carefully, if you face any issues regarding indentations, just let me know.

Function MaxMagnitude(integer x, integer y) returns integer max

//checking if absolute value of x is bigger than that of y

   if AbsoluteValue(x)>AbsoluteValue(y)

      //setting x as max

      max=x

   else

      //setting y as max

      max=y

  

Function Main() returns nothing

   //defining three integer variables

   integer x

   integer y

   integer max

   //reading x and y

   x = Get next input

   y = Get next input

   //finding value with maximum magnitude

   max = MaxMagnitude(x,y)

   //displaying max

   Put max to output

//OUTPUT screenshot

Add a comment
Know the answer?
Add Answer to:
*Using Coral Language* Write a function MaxMagnitude with two integer parameters that returns the largest magnitude...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a method MaxMagnitude with two integer input parameters that returns the largest magnitude value.

    6.12 LAB: Max magnitudeWrite a method MaxMagnitude with two integer input parameters that returns the largest magnitude value. Use the method in a program that takes two integer inputs, and outputs the largest magnitude value.Ex: If the inputs are 5 7 , the method returns:7Ex: If the inputs are -8 -2, the method returns:-8Note: The method does not just return the largest value, which for -8-2 would be -2. Though not necessary, you may use the absolute-value built-in math method.Your...

  • *Coral Language* Write a program that first gets a list of six integers from input. The first five values are the intege...

    *Coral Language* Write a program that first gets a list of six integers from input. The first five values are the integer list. The last value is the upper threshold. Then output all integers less than or equal to the threshold value. Ex: If the input is 50 60 140 200 75 100, the output is: 50 60 75 For coding simplicity, follow every output value by a space, including the last one. Such functionality is common on sites like...

  • NEED IN CORAL LANGUAGE ONLY When analyzing data sets, such as data for human heights or...

    NEED IN CORAL LANGUAGE ONLY When analyzing data sets, such as data for human heights or for human weights, a common step is to adjust the data. This can be done by normalizing to values between 0 and 1, or throwing away outliers. For this program, adjust the values by subtracting the smallest value from all the values. The input consists of five integers. Ex: If the input is 30 50 10 70 65, the output is: 20 40 0...

  • use coral language please question 1 Function ConvertFeetToInches(integer feetToConvert) returns integer resultInches resultInches = feetToConvert *...

    use coral language please question 1 Function ConvertFeetToInches(integer feetToConvert) returns integer resultInches resultInches = feetToConvert * 12 Function Main() returns nothing integer resultInches integer feetToConvert feetToConvert = Get next input // Your solution goes here Put feetToConvert to output Put " feet are " to output Put resultInches to output Put " inches." to output question 2 Function GetRecArea(float recHeight, float recWidth) returns float recArea // Calculate recArea: recArea = 0 Function Main() returns nothing float userHeight float userWidth userHeight...

  • write a c program 14. Write a function that gets two numbers (as parameters) and returns...

    write a c program 14. Write a function that gets two numbers (as parameters) and returns their sum. Write a program that uses the above function to find the sum of the elements in an array contains 10 numbers.

  • Write MARIE assembly language programs that do the following: I. Write a program that inputs thre...

    Write MARIE assembly language programs that do the following: I. Write a program that inputs three integers, a, b, and c, in that order. It computes the following ia-bi-fc+ c The result should be written to output 2. Write a program that inputs integers, s. y, and z. It outputs the difference of the langest and first element entered. You may assume x. y, and z all have different values. So if 8, 12, and 9 are input, the output...

  • Using Java: 1. Recursive Multiplication Write a recursive function that accepts two arguments into the parameters...

    Using Java: 1. Recursive Multiplication Write a recursive function that accepts two arguments into the parameters x and y. The function should return the value of x times y. Remember, multiplication can be performed as repeated addition as follows: 5×6=6+6+6+6+6 2. Recursive findings Write a recursive boolean method named reFinding. The method should search an array for a specified value, and return true if the value is found in the array, or false if the value is not found in...

  • Task 4: a) Write a function named change() that has an integer parameter and six integer...

    Task 4: a) Write a function named change() that has an integer parameter and six integer reference parameters named hundreds, fifties, twenties, tens, fives, and ones. The function is to consider the passed integer value as a dollar amount and convert the value into the fewest number of equivalent bills. Using the reference parameters, the function should alter the arguments in the calling function. b) Include the function written in part a in a working program. Make sure your function...

  • Function Name: zip_d Parameters: two equal-sized lists Returns: a dictionary Description: Write a function, zip_d, that...

    Function Name: zip_d Parameters: two equal-sized lists Returns: a dictionary Description: Write a function, zip_d, that takes a two equal-sized lists as parameters, and zips each list into a dictionary. Sample Inputs/Outputs: Example Call: zip_d([1,2,3], ['a','b','c']) Expected Return: {1: 'a', 2: 'b', 3: 'c'} Example Call: zip_d([‘a’,’b’,’c’],[9.8,7.6,5.4]) Expected Return: {‘a’:9.8, ’b’:7.6, ’c’:5.4} please answer in python

  • Write a Python function, called counting, that takes two arguments (a string and an integer), and...

    Write a Python function, called counting, that takes two arguments (a string and an integer), and returns the number of digits in the string argument that are not the same as the integer argument. Include a main function that inputs the two values (string and integer) and outputs the result, with appropriate labelling. You are not permitted to use the Python string methods (such as count(), etc.). Sample input/output: Please enter a string of digits: 34598205 Please enter a 1-digit...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT