Question: Problem Statement Write a Java method foo that accepts three integer parameters named a, b, and c as well as one boolean parameter named add
Problem Statement Write a Java method foo that accepts three integer parameters named a, b, and c as well as one boolean parameter named add.
When add is true the method returns the sum of the biggest and smallest integers, otherwise it returns the biggest integer minus the smallest integer; however, if the value provided for a is 10, then the method returns the sum of all three values no matter what.
Here are several sample calls with return values:
Sample Data foo( 4, 3, 8, true) returns 11 foo( 9, 9,10, false) returns 1 foo( 4, 3, 8, false) returns 5 foo( 1, 1, 1, false) returns 0 foo( 9,10, 9, true) returns 19 foo(29, 9, 1, true) returns 30 foo(10, 9, 9, false) returns 28 foo( 0, 0, 7, true) returns 7
Method Header public static int foo (int a, int b, int c, boolean add)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
