public class ArgumentDemo
1: //ArgumentDemo.java
2:
3: import java.util.Scanner;
4:
5: /**
6: * A demonstration of using 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:
17: for (int i = 0; i < nextScore.length; i++)
18: nextScore[i] = firstScore + 5 * i;
19:
20: for (int i = 0; i < nextScore.length; i++)
21: {
22: double possibleAverage = getAverage(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 getAverage
31: (
32: int n1,
33: int n2
34: )
35: {
36: return (n1 + n2) / 2.0;
37: }
38: }