Complete the following function. public static int Score(int test1a, int test1b,
ID: 669937 • Letter: C
Question
Complete the following function.
public static int Score(int test1a, int test1b, int test2a, int test2b)
{// A student took test one twice (one in class and one out of class)
// called test1a and test1b.
// The same is true for test2(one in class and one out of class)
// called test2a and test2b.
// This function is to return the students score on the two tests by
// adding
// 1. the larger of test1a and test1b
// plus
// 2. the larger of test2a and test2b
// Use the Math.max method to compute the return value.
Explanation / Answer
public static int Score(int test1a, int test1b, int test2a, int test2b)
{// A student took test one twice (one in class and one out of class)
int sum;
int max1=Math.max(test1a, test1b);
int max2=Math.max(test2a, test2b);
sum=max1+max2;
// called test1a and test1b.
// The same is true for test2(one in class and one out of class)
// called test2a and test2b.
// This function is to return the students score on the two tests by
// adding
// 1. the larger of test1a and test1b
// plus
// 2. the larger of test2a and test2b
// Use the Math.max method to compute the return value.
return sum;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.