Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CHALLENGE ACTIVITY 9.6.2: Method call in expression. Assign to maxSum the max of (numa, numB) PLUS the max of (numy, numz). Use just one statement.

image text in transcribedimage text in transcribed

CHALLENGE ACTIVITY 9.6.2: Method call in expression. Assign to maxSum the max of (numa, numB) PLUS the max of (numy, numz). Use just one statement. Hint: Call findMax() twice in an expression. 2 3 public class SumOfMax { 4 public double findMax(double num, double num2) { 5 double maxVal; 6 7 // Note: if-else statements need not be understood to 8 // complete this activity 9 if (numl > num2) { // if num1 is greater than num2, 10 maxVal num1; // then num1 is the maxVal. 11 } 12 else { // Otherwise, 13 maxVal num2; // num2 is the maxVal. 14 } 15 return maxVal; 16 } 17 18 public static void main(String [] args) { 19 double numA 5.0; 20 double numB 10.0: public static void main(String [] args) { double numA = 5.0; double numb - 10.0; double numY = 3.0; double numz = 7.0; double maxSum = 0.0; 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 } // Use object maxFinder to call the method SumofMax maxFinder = new SumOfMax(); maxSum = ( findMax(numA, numB) ) + ( findMax(numX, numy)); printf("maxSum is %.1f ", maxSum); System.out.print("maxSum is: " + maxSum); } Run Failed to compile SumofMax.java:27: error: non-static method findMax (double, double) cannot be referenced from a static context max Sum = ( findMax (numA, numB) ) + ( findMax (numX, numy) ); SumofMax.java:27: error: cannot find symbol maxSum = ( findMax (numA, numB) ) + ( findMax (numX, numY) ); symbol: variable numX location: class SumOfMax SumofMax.java:29: error: cannot find symbol

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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