Question
Asked Nov 21, 2019
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

Expert Answer

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;

          }

          //Print the table header

          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:

help_outline

Image Transcriptionclose

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[] int score1[]= new int[10] int score2[] new int[10]; = 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");

fullscreen
Step 2

Screenshot of program #2:

help_outline

Image Transcriptionclose

/Get the marks from the user score[il-s.nextInt (); scorei[i-s.nextInt ( ); score2[i]-s.nextInt (); //Calculate the total marks sum-score[i]+score1 [i] +score2 [ i] ; 1/Calculate the average avg[i-sum/3; } //Print the table header System.out.print("STUDENT\t Exam 1\tExam 2\tExam 3\tAverage"); 1/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] )

fullscreen
Step 3

Screenshot of output #1...

help_outline

Image Transcriptionclose

Enter details of student: 1 Enter the marks for Exam1, Exam2, and Exam3 10 11 12 Enter details of student: 2 Enter the marks for Examl, Exam2, and Exam3 12 13 12 Enter details of student: 3 Enter the marks for Examl, Exam2, and Exam3 14 10 12 Enter details of student: 4 Enter the marks for Exam1, Exam2, and Exam3 12 1516 Enter details of student: 5 Enter the marks for Exam1, Exam2, and Exam3 11 16 10 Enter details of student: 6 Enter the marks for Examl, Exam2, and Exam3 14 13 15 Enter details of student: 7 Enter the marks for Exam1, Exam2, and Exam3 10 16 14 Enter details of student: 8 Enter the marks for Examl, Exam2, and Exam3 10 15 13 Enter details of student: 9 Enter the marks for Examl, Exam2, and Exam3 17 18 13

fullscreen

Want to see the full answer?

See Solution

Check out a sample Q&A here.

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.

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

Q: what could be the value of the register $t1 after excuting the instruction SLL $t1,$t0,1 if the valu...

A: SSL acronym as Shift Left Logical. It only applied to bits. It applied to the right-most position of...

question_answer

Q: What are the SQL query commands to create the tables (attached) with appropriate attributes and data...

A: Primary key:A primary key is a minimal array of attributes (columns) in a table in which tuples (row...

question_answer

Q: Write a simplified expression for the Boolean function defined by each of the following Kmaps.

A: K-map stands for Karnaugh map that provides a way of grouping the expression together on the basis o...

question_answer

Q: Define a function CoordTransform() that transforms its first two input parameters xVal and yVal into...

A: This program takes two inputs from the user. The CoordTransform() function is used to transform the ...

question_answer

Q: In Python Use the Design Recipe to write a function has_duplicates, which consumes a list and return...

A: This program returns true when a list has duplicate value, if the list has not any duplicate value t...

question_answer

Q: I am trying to use printf for a system.out.print statement. I dont understand how to turn it to a pr...

A: The printf statement of the given print statement is following:System.out.printf("The total area for...

question_answer

Q: This is for python

A: The expression would be:dow[len(dow)-2] The program is following:dow = "help!"print(dow[len(dow)-2])

question_answer

Q: Simplify the following Boolean function and expression, using four-variable maps  b) F = x’z + w’xy’...

A: (a) F = x’z + w’xy’ + w(x’y + xy’)= x’z + w’xy’ + wx’y + wxy’ Mapping the above expression into the ...

question_answer

Q: If you wanted to apply an exception for the current subnet, what would you type?

A: Explanation:The user can type the following on linux to apply exception for the current subnet,defau...