# using java a class of 10 students that will take 3 exams. use 3 arrays to hold the scores for each student and another to hold the average of the 3 exams for each student. print a table with the scores and average

Question
31 views

using java a class of 10 students that will take 3 exams. use 3 arrays to hold the scores for each student and another to hold the average of the 3 exams for each student. print a table with the scores and average

check_circle

Step 1

A Java program for the given criteria as follows,

File name: “StudentScore.java”

import java.util.Scanner;

public class StudentScore

{

public static void main(String[] args)

{

//Create Scanner object

Scanner s=new Scanner(System.in);

//Declare the variables

int i, sum;

//Declare three arrays to hold marks

int score[] = new int[10];

int score1[]= new int[10];

int score2[]= new int[10];

//Declare array to hold average

double avg[]=new double[10];

//Assign the initial values

sum=0;

//create for loop to iterate over 10 students

for (i=0; i<10; i++)

{

//Prompt the user to enter marks for three exams

System.out.println("Enter details of student: "+(i+1));

System.out.println("Enter the marks for Exam1, Exam2, and Exam3");

//Get the marks from the user

score[i]=s.nextInt();

score1[i]=s.nextInt();

score2[i]=s.nextInt();

//Calculate the total marks

sum=score[i]+score1[i]+score2[i];

//Calculate the average

avg[i]=sum/3;

}

System.out.print("STUDENT\tExam 1\tExam 2\tExam 3\tAverage");

//Create loop to display result

for (i=0;i<10;i++)

{

//Print the results

System.out.println("\n"+(i+1)+"\t"+score[i]+"\t"+score1[i]+"\t"+score2[i]+"\t"+avg[i]);

}

}

}

Screenshot of program #1:

Step 2

Screenshot of program #2:

Step 3

Screenshot of output #1...

### Want to see the full answer?

See Solution

#### Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in
EngineeringComputer Science