Advertisement
Guest User

Untitled

a guest
Jan 27th, 2020
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class SumOfMax {
  4.    public double findMax(double num1, double num2) {
  5.       double maxVal;
  6.  
  7.       // Note: if-else statements need not be understood to
  8.       // complete this activity
  9.       if (num1 > 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;
  21.       double numY = 3.0;
  22.       double numZ = 7.0;
  23.       double maxSum = 0.0;
  24.  
  25.       // Use object maxFinder to call the method
  26.       SumOfMax maxFinder = new SumOfMax();
  27.  
  28.       maxSum = findMax(numA, numB) + findMax(numY,numZ);/* Your solution goes here  */
  29.  
  30.       System.out.print("maxSum is: " + maxSum);
  31.    }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement