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
sweet [91]
3 years ago
14

CTIVITY 2.2.2: Method call in expression. Assign to maxSum the max of (numA, numB) PLUS the max of (numY, numZ). Use just one st

atement. Hint: Call findMax() twice in an expression.
Computers and Technology
1 answer:
barxatty [35]3 years ago
4 0

Answer:

The one statement is:

maxSum = maxFinder.findMax(numA, numB) + maxFinder.findMax(numY, numZ);

Explanation:

  • The given code in the Activity contains a method named findMax() in class SumOfMax which has two parameters  num1 and num2. The method returns the maximum value after comparing the values of num1 and num2.
  • In the main() function, 4 variables numA, numB, numY and numZ of type double are declared and assigned the values numA=5.0, numB=10.0, numY=3.0 and numZ=7.0. Also a variable maxSum is declared and initialized by 0.
  • After that an object named maxfinder of SumOfMax class is created using keyword new.

                 SumOfMax maxFinder = new SumOfMax();

  • We can invoke the method findMax() by using reference operator (.) with the object name.
  • So the task is to assign to maxSum the maximum of numA, numB plus maximum of numY, numZ in one statement.  
  • Using findMax() method we can find the maximum of numA and numB and also can find the maximum numY and numZ. The other requirement is add (PLUS) the maximum of numA, numB to maximum of numY, numZ.
  • The statement used for this is given below:

maxSum = maxFinder.findMax(numA, numB) + maxFinder.findMax(numY, numZ);

  • So as per the hint given in the question statement, findMax() function is being called twice, at first to find the maximum between the values of variables numA and numB and then to find the maximum between the values of numY and numZ.
  • According to the given values of each of these variables:

                    numA=5.0, numB=10.0,

       So                  numB>numA

  • Hence findMax returns numB whose value is greater than numA
  • Now findMax() is being called again for these variables:

                              numY=3.0 and numZ=7.0    

        So                  numZ>numY as 7.0>3.0

  • Hence findMax() returns numZ whose value is 7.0
  • Finally according to the statement maximum will be added and the result of this addition will be assigned to variable maxSum
  • 10.0 is added to 7.0 which makes 17.0
  •        System.out.print("maxSum is: " + maxSum);  

        This statement displays the value of maxSum which is 17.0

You might be interested in
Who can add entries to value log
miskamm [114]

Answer:

b

Explanation:

3 0
3 years ago
Show a single view of an object, but show it in a way that makes it look 3-D, as your eye would see it.
Fofino [41]

A square from the front

5 0
4 years ago
Which text features does this section contain? Check all that apply.
NISA [10]

which ones apply manuelh


6 0
3 years ago
Just answer in five-line. Question:
Eddi Din [679]

Answer:

It is a half-duplex serial transmission mode, and this can be provided through the RS-485 two wired electrical interface. And this can be connected to the ethernet if required, connect to the LAN, and finally transmitting the video footage to all the screens. And the two reasons are:

1. Noiseless

2. Allows around 32 receivers.

Explanation:

Please check the answer.

3 0
3 years ago
Need answer ASAP. No links
DIA [1.3K]

Answer:

A <b>

Normally AD and BC are written in bold letters.

for example : The terms anno Domini (AD) and before Christ (BC).

Within available option the best option to choose is <b> hope it helped

5 0
3 years ago
Other questions:
  • a reviewer is required to enter a reason in the comments field only when a candidate is recommended to be hired. which action ca
    8·1 answer
  • How can vlan hopping attacks be prevented on a network?
    10·1 answer
  • Sharing a workbook helps to complete ________ (A, tasks) (B,changes) (C, typing) on time. Multiple people acssessing the workboo
    9·1 answer
  • Put the steps of the decision-making process in the correct order.
    12·1 answer
  • How can you achieve an effect like that shown in the image?
    7·2 answers
  • Generally considered to be the most important information security policies, what item below defines the actions a user may perf
    11·1 answer
  • Which type of virus includes protective code that prevents outside examination of critical elements?
    14·1 answer
  • Ad identifies and describes at least four ways to prevent downloading of spyware, adware, and viruses to computer
    9·1 answer
  • What was the name of first computer?
    14·1 answer
  • QUESTION 5
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!