Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SodaSurvey
- {
- public static void main(String[] args)
- {
- int[][] scores = { {3, 4, 5, 2, 1, 4, 3, 2, 4, 4},
- {2, 4, 3, 4, 3, 3, 2, 1, 2, 2},
- {3, 5, 4, 5, 5, 3, 2, 5, 5, 5},
- {1, 1, 1, 3, 1, 2, 1, 3, 2, 4} };
- int numSodas = scores.length;
- int numStudents = scores[0].length;
- int[] sodaSum = new int[numSodas];
- int[] studentSum = new int[numStudents];
- System.out.println("Survey Averages");
- System.out.println("---------------\n");
- double sodaAverage;
- for(int i = 0; i < scores.length; i++)
- {
- for(int k = 0; l < scores[0].length; i++)
- {
- sodaSum[i] += scores[i][j];
- }
- sodaAverage = (double) sodaSum[i] / numStudents;
- System.out.println("Soda #" + (i + 1) + ":" + sodaAverage)
- }
- System.out.println("---")
- double studentAverage;
- for(int i = 0; i < scores[0].length; i++)
- {
- studentAverage = (double) studentSum[i] / numSodas;
- System.out.println("Student #" + (i + 1) + ":" + studentAverage);
- }
- }
- }
Add Comment
Please, Sign In to add comment