Program.java
import java.util.*;
public class Program {
/**
* @param args
*/
public static void main(String[] args) {
TestScores ts = new TestScores(5);
Scanner scan=new Scanner(System.in);
int score=0;
for(int i=0; i<5; i++)
{
System.out.println("Enter a score");
score=scan.nextInt();
ts.Addscore(i, score);
}
int[] scores2=ts.GetScores();
for (int i=0;i<5;i++)
{
System.out.println(scores2[i]);
}
}
}
TestScores.Java
public class TestScores {
private int number;
private int[] scores;
public TestScores(int numberOfScores)
{
number=numberOfScores;
scores=new int[number];
}
public void Addscore(int i, int score)
{
scores[i]=score;
}
public int[] GetScores()
{
return scores;
}
}
No comments:
Post a Comment