public class ArgumentDemo
1:
2: import java.util.*;
3:
4: /**
5: A program to demonstrate the use of
6: indexed variables as arguments.
7: */
8: public class ArgumentDemo
9: {
10: public static void main(String[] args)
11: {
12: Scanner keyboard = new Scanner(System.in);
13: System.out.println("Enter your score on exam 1:");
14: int firstScore = keyboard.nextInt( );
15: int[] nextScore = new int[3];
16: int i;
17: double possibleAverage;
18: for (i = 0; i < nextScore.length; i++)
19: nextScore[i] = 80 + 10*i;
20: for (i = 0; i < nextScore.length; i++)
21: {
22: possibleAverage = average(firstScore, nextScore[i]);
23: System.out.println("If your score on exam 2 is "
24: + nextScore[i]);
25: System.out.println("your average will be "
26: + possibleAverage);
27: }
28: }
29:
30: public static double average(int n1, int n2)
31: {
32: return (n1 + n2)/2.0;
33: }
34: }
35:
36:
37:
38:
39:
40:
41: