Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

taking user input in array in java using constructor

public class ScoresDemo {

    public static void main(String[] args) {
        double testScores[] = new double [5];
        TestScores scores = new TestScores(testScores);
        Scanner scan = new Scanner(System.in);

        for(int i = 0; i < testScores.length; i++) {
            System.out.println("Enter some test scores: ");
            testScores[i] = scan.nextDouble();
        }
        System.out.println("The average of the test scores is " + scores.averageScores());
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #user #input #array #java #constructor
ADD COMMENT
Topic
Name
6+9 =