Question

Question 3 (1 point) Question 3) METHODs to our Madness: Use the pseudocode methods below to...

Question 3 (1 point)

Question 3) METHODs to our Madness: Use the pseudocode methods below to answer the questions starting on the next page.

FIRST METHOD:

COMMENT parameters should be integers

METHOD largestValue(parameters: num1, num2)

BEGIN

            IF(num1 >= num2) THEN

result ← num1

ELSE

result ← num2

            ENDIF

END largestValue

SECOND METHOD:

COMMENT parameters should be doubles

METHOD largestValue(parameters: num1, num2)

BEGIN

            IF(num1 >= num2) THEN

result ← num1

ELSE

result ← num2

            ENDIF

            RETURN result

END largestValue

THIRD METHOD:

COMMENT parameters should be integers

METHOD largestValue(parameters: num1, num2, num3)

BEGIN

IF(num1 >= num2 AND num1 >= num3) THEN         

result ← num1

ELSE IF (num2 >= num3) THEN

result ← num2

            ELSE

result ← num3

ENDIF

RETURN result

END largestValue

Given the pseudocode methods above and on the previous page,which method corresponds to each of the method calls specified?

What would that method return based on the arguments listed?

If nothing would be returned, please write “NO RETURN” in the box.

A) CALL largestValue(3, 5, 3) - (10 points)

B) CALL largestValue(3, 5) - (10 points)

C) CALL largestValue(3.0, 5.5) - (10 points)

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

A) largestValue(3,5,3) has 3 arguments which are ints.
Signature of 3rd method is
THIRD METHOD : METHOD largestValue(num1, num2, num3) is invoked

num2>=num3, so, result contains 5. Answer is 5

B) largestValue(3,5) has 2 ints. So, FIRST METHOD will be invoked. It is not returning anything. So, ans is
NO RETURN

C) largestValue(3.0,5.5) has 2 doublts as parameters. so, SECOND METHOD will be invoked. Answer is num2.
So, 5.5

Add a comment
Know the answer?
Add Answer to:
Question 3 (1 point) Question 3) METHODs to our Madness: Use the pseudocode methods below to...
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
  • Question 5 (1 point) userGuess ← 0, secretNumber ← 5 PRINT “Enter a number between 1...

    Question 5 (1 point) userGuess ← 0, secretNumber ← 5 PRINT “Enter a number between 1 and 10” READ userGuess WHILE (userGuess < 1 OR userGuess > 10) PRINTLINE “That is not between 1 and 10. Try again.” READ userGuess ENDWHILE IF (userGuess == secretNum) THEN PRINTLINE “That’s right! ”, userGuess, “ is the secret!” ELSE PRINTLINE userGuess, “ is not the secret!” ENDIF What is the first WHILE loop being used for? Question 5 options: Input validation Random number...

  • in python 3.0 please Question 3 (1 point) What is the value of result after the...

    in python 3.0 please Question 3 (1 point) What is the value of result after the following code snippet? num1 = 20 num2 = 10 num3 = 2 result = num1 // num2 / num3 print(result) The code has an error 01.0 0 0.0 0 0.25

  • Please select the output: main         declare X as integer, Y as integer                        &nbsp

    Please select the output: main         declare X as integer, Y as integer                                 set x=1                                 set y=2                                 call sub(x, y)                                 write x                                 write y End program Subprogram sub( integer Num1 as ref, Integer Mum2 as reference)                                                              declare x as integer                                                 set Num1 = 3                                                 set Num2 = 4                                                 set x= 5                                                 write x end subprogram           Please select one:      5/42, 5/34, 5/32, 5/24 What is the output of this...

  • Hello, I need help writing the two methods to print a triangle shape in java. An...

    Hello, I need help writing the two methods to print a triangle shape in java. An example of the shape is as follows: 9 8 7 6 5 4 3 8 7 6 5 4 3 7 6 5 4 3 6 5 4 3 5 4 3 4 3 3 One method should be defined as "public static void printPattern(int num1, int num2, Boolean ascending)". This method will print a upper-triangle matrix-like layout filled will a sequence of integers...

  • I couldn't find where to comment. But it has to be written in C++!!!!! Task-1: Rational...

    I couldn't find where to comment. But it has to be written in C++!!!!! Task-1: Rational fractions are of the form a / b, in which a and b are integers and ! ≠ 0. In this exercise, by ‘‘fractions’’ we mean rational fractions. Suppose a / b and c / d are fractions. Arithmetic operations and relational operations on fractions are defined by the following rules: Arithmetic Operations: a/b + c/d = (ad + bc)/bd a/b – c/d =...

  • I am supposed to a pseudocode function named max that accepts two integer values as arguments...

    I am supposed to a pseudocode function named max that accepts two integer values as arguments and returns the value that is greater of the two. Use the function in a program that prompts the user to enter two integer values. The program should display the value that is greater of the two. Is everything correct and complete? //Pseudocode //This function takes two integers as parameters: x and y Begin : Max(x,y) If(x>y) then MAX=x Else MAX=y End if Return...

  • Rational will be our parent class that I included to this post, Implement a sub-class MixedRational....

    Rational will be our parent class that I included to this post, Implement a sub-class MixedRational. This class should Implement not limited to: 1) a Constructor with a mathematically proper whole, numerator and denominator values as parameters. 2) You will override the: toString, add, subtract, multiply, and divide methods. You may need to implement some additional methods, enabling utilization of methods from rational. I have included a MixedRational class with the method headers that I used to meet these expectations....

  • (3) Methods That Return a Value (10 points) Write a method dominant that accepts three integers...

    (3) Methods That Return a Value (10 points) Write a method dominant that accepts three integers as parameters and returns true if any one of the three integers is larger than the sum of the other two integers. The integers might be passed in any order, so the largest value could be any of the three. If no value is larger than the sum of the other two, your method should return false. For example, the call of dominant (4,...

  • Give answer according to fill in the blanks. 1.Define a class called Fraction . This class...

    Give answer according to fill in the blanks. 1.Define a class called Fraction . This class is used to represent a ratio of two integers.Include mutator methods that allow the user to set the numerator and the denominator. Also include a method that returns the value of numerator divided by denominator as a double . Include an additional method that outputs the value of the fraction reduced to lowest terms (e.g., instead of outputting 20/60, the method should output 1/3)....

  • Please help me. package a1; public class Methods {    /*    * Instructions for students:...

    Please help me. package a1; public class Methods {    /*    * Instructions for students: Use the main method only to make calls to the    * other methods and to print some testing results. The correct operation of    * your methods should not depend in any way on the code in main.    *    * Do not do any printing within the method bodies, except the main method.    *    * Leave your testing code...

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