Download presentation
Presentation is loading. Please wait.
1
Computing Adjusted Quiz Total Score
2
Main Algorithm Get 12 quiz scores Get 12 adjustment values
Compute 12 adjusted scores by adding the corresponding adjustment value to each score Compute the sum of the two lowest adjusted scores Compute the sum of the 12 adjusted scores Compute the total adjusted quiz score by subtracting the sum of the two lowest adjusted scores from the sum of the 12 adjusted scores Print the total adjusted quiz score
3
Java Code public class TotalAdjustedQuizScore { public static void main(String[] args) { // Get 12 quiz scores // Get 12 adjustment values // Compute 12 adjusted scores by adding the // corresponding adjustment value to each score // Compute the sum of the two lowest adjusted scores // Compute the sum of the 12 adjusted scores // Compute the total quiz score by subtracting the // sum of the two lowest adjusted scores from the sum // of the 12 adjusted scores // Print the total quiz score } }
4
Java Code Expanded public class TotalAdjustedQuizScore { public static void main(String[] args) { // Get 12 quiz scores int[] score = {7, 6, 10, 9, 5, 4, 6, 7, 8, 5, 0, 8}; // Get 12 adjustment values int[] adjustmentValue = {1, 2, 0, 0, 0, 2, 1, 0, 2, 1, 0, 1}; // Compute 12 adjusted scores by adding the // corresponding adjustment value to each score int [] adjustedScore = addArrays(score,adjustmentValue,12);
5
Java Code Expanded (Cont’d)
// Compute the sum of the two lowest adjusted scores int sumTwoLowest = getSumOfTwoLowestElements(adjustedScore,12); // Compute the sum of the 12 adjusted scores int sumAdjustedScores = getSumOfArrayElements(adjustedScore,12); // Compute the total quiz score by subtracting the // sum of the two lowest adjusted scores from the sum // of the 12 adjusted scores int totalAdjustedScore = sumAdjustedScore - sumTwoLowest; // Print the total quiz score System.out.println("Total Adjusted Quiz Score = " totalAdjustedScore); }
6
Java Code Expanded (Cont’d)
public static int[] addArrays(int[] a, int[] b, int n) { int[] c = {9,10,10,9,5,6,7,7,10,6,0,9}; return c; } public static int getSumOfTwoLowestElements(int[] a, int n) { return 5; } public static int getSumOfArrayElements(int[] a, int n) { return 85; } }
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.