Question

IN JAVA WITH COMMENTS, The assignment: This program inputs the names of 5 students and the...

IN JAVA WITH COMMENTS, The assignment: This program inputs the names of 5 students and the (integer) grades they earned in 3 tests. It then outputs the average grade for each student. It also outputs the highest grade a student earned in each test, and the average of all grades in each test.

Your output should look like this:

Mary's average grade was 78.8%

Harry's average grade was 67.7%

etc... :

In test 1 the highest grade was 93% and the average was 89.2%

In test 2........etc

Your main method should be modular.

Write a method that inputs the 5 names into an array (one dimensional), and returns this array to main

Write a method that inputs the 15 (integer) test grades into a (two-dimensional) array, and returns this array to main.

Write a method that calculates the students averages and stores them in an array , and returns this array to main

Write a method that calculates the average grade for each test and stores them in an array, and returns this array to main

Write a method that determines the highest grade for each test and stores this in an array , and returns this array to main. MAIN will print all the information. The printing could be done easily by the methods instead of having to store the information in an array, but this will give you practice in arrays and methods - all useful for the final exam.

Thanks a lot, please include the comments.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

output:

code:

import java.util.*;
public class Main
{   
public static String[] name_i() /*this function will take student name from user and return array of student name*/
{
String[] name=new String[5]; /*here we make array of string*/
Scanner sc=new Scanner(System.in);
for(int i=0;i<5;i++)
{
System.out.print("Enter Student "+(i+1)+ " name:");
name[i]=sc.nextLine(); /*here we take Student name input*/
}
return name;
}
  
public static int[][] test_i(String name[]) /*this function will take student test mark from user and return test mark array*/
{
int[][] test=new int[5][3]; /*here we initialize 2D array for store student test mark*/
Scanner sc=new Scanner(System.in);
for(int i=0;i<5;i++)
{
for(int j=0;j<3;j++)
{
System.out.print("Enter Student "+name[i]+ " test "+(j+1)+" mark:");
test[i][j]=sc.nextInt(); /*here we take student test mark input*/
}
}
return test;
}
  
public static float[] student_a(int t_mark[][]) /*in this function we find the average of student mark and return array*/
{
float[] student_avg_mark=new float[5]; /*in this array we will store student_avg_mark*/
float sum=0;
for(int i=0;i<5;i++)
{ sum=0;
for(int j=0;j<3;j++)
{
sum=sum+t_mark[i][j]; /*here we do sum of student mark*/
}
student_avg_mark[i]=sum/3; /*than here we store sum into student_avg_mark array*/
}
return student_avg_mark; /*here we return student_avg_mark array*/
}
  
public static float[] test_a(int t_mark[][]) /*in this function we find the average of test mark and return array*/
{
float[] test_avg_mark=new float[3]; /*in this array we will store test_avg_mark*/
float sum=0;
for(int i=0;i<3;i++)
{   
sum=0;
for(int j=0;j<5;j++)
{
sum=sum+t_mark[j][i]; /*here we do sum of test mark*/
}
test_avg_mark[i]=sum/5; /*than here we store sum into test_avg_mark array*/
}
return test_avg_mark; /*here we return student_avg_mark array*/
}
  
public static int[] test_H(int t_mark[][]) /*in this function we find the test highest mark*/
{
int[] test_high_mark=new int[3]; /*in this array we will store test_highest_mark*/
int max=0;
for(int i=0;i<3;i++)
{ max=0; /*here we declare max variable with 0*/
for(int j=0;j<5;j++)
{
/*here we compare max with the test mark if condition getting true than we store that value into max*/
if(max<t_mark[j][i])
{
max=t_mark[j][i];   
}
}
test_high_mark[i]=max; /*after inner loop execute we store max into test_high_mark array*/
}
return test_high_mark; /*here we return test_high_mark array*/
}
  
   public static void main(String[] args)
   {   
   /*here we instialize 5 different types array for store value which is return from function*/
   String[] name=new String[5];
   int[][] test_mark=new int[5][3];
   float[] student_avg_mark=new float[5];
   float[] test_avg_mark=new float[3];
   int[] test_high_mark=new int[3];
   name=name_i(); /*here we call name_i function and store student name in name array*/
   test_mark=test_i(name); /*here we call test_i function and store test mark in test_mark array*/
   student_avg_mark=student_a(test_mark);/*here call student_a function and store student averagemark in student_avg_mark*/
   test_avg_mark=test_a(test_mark);/*here we call test_a function and store test average mark in test_avg_mark array*/
   test_high_mark=test_H(test_mark);/*here we call test_H function and store test highest mark in test_high_mark array*/
  
   for(int i=0;i<5;i++)
   {
   System.out.println(name[i]+" average grade was "+String.format("value is %.1f",student_avg_mark[i])+"%");
   }
   for(int i=0;i<3;i++)
   {
   System.out.println("In test "+(i+1)+" highest grade was "+test_high_mark[i]+"% and the average was "+
   String.format("value is %.1f",test_avg_mark[i])+"%");
   }
   }
}

Add a comment
Know the answer?
Add Answer to:
IN JAVA WITH COMMENTS, The assignment: This program inputs the names of 5 students and the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PSEUDOCODE and PYTHON source code! Program 4: Design (pseudocode) and implement (source code) a program (name...

    PSEUDOCODE and PYTHON source code! Program 4: Design (pseudocode) and implement (source code) a program (name it MinMaxAvg) to determine the highest grade, lowest grade, and the average of all grades in a 4-by-4 two-dimensional arrays of integer grades (representing 4 students’ grades on 4 tests). The program main method populates the array (name it Grades) with random grades between 0 and 100 and then displays the grades as shown below. The main method then calls method minMaxAvg()that takes a...

  • [JAVA/chapter 7] Assignment: Write a program to process scores for a set of students. Arrays and...

    [JAVA/chapter 7] Assignment: Write a program to process scores for a set of students. Arrays and methods must be used for this program. Process: •Read the number of students in a class. Make sure that the user enters 1 or more students. •Create an array with the number of students entered by the user. •Then, read the name and the test score for each student. •Calculate the best or highest score. •Then, Calculate letter grades based on the following criteria:...

  • Write a complete C++ program that reads students names and their test scores from an input...

    Write a complete C++ program that reads students names and their test scores from an input text file. The program should output each student’s name followed by the test scores and the relevant grade in an output text file. It should also find and display on screen the highest/lowest test score and the name of the students having the highest/lowest test score, average and variance of all test scores. Student data obtained from the input text file should be stored...

  • Write a program to calculate students’ average test scores and their grades. You may assume the...

    Write a program to calculate students’ average test scores and their grades. You may assume the following data: Johnson 85 83 77 91 76 Aniston 80 90 95 93 48 Cooper 78 81 11 90 73 Gupta 92 83 30 69 87 Blair 23 45 96 38 59 Clark 60 85 45 39 67 Kennedy 77 31 52 74 83 Bronson 93 94 89 77 97 Sunny 79 85 28 93 82 Smith 85 72 49 75 63 Use three...

  • Write a program to calculate students’ average test scores and their grades. You may assume the...

    Write a program to calculate students’ average test scores and their grades. You may assume the following data: Johnson 85 83 77 91 76 Aniston 80 90 95 93 48 Cooper 78 81 11 90 73 Gupta 92 83 30 69 87 Blair 23 45 96 38 59 Clark 60 85 45 39 67 Kennedy 77 31 52 74 83 Bronson 93 94 89 77 97 Sunny 79 85 28 93 82 Smith 85 72 49 75 63 Use three...

  • Using the following parallel array and array of vectors: // may be declared outside the main...

    Using the following parallel array and array of vectors: // may be declared outside the main function const int NUM_STUDENTS =3; // may only be declared within the main function string Students[NUM_STUDENTS] = {"Tom","Jane","Jo"}; vector <int> grades[NUM_STUDENTS] {{78,98,88,99,77},{62,99,94,85,93}, {73,82,88,85,78}}; Write a C++ program to run a menu-driven program with the following choices: 1) Display the grades 2) Add grade 3) Remove grade for all students for a selected assignment 4) Display Average for each student 5) Display the name of...

  • Write a C++ program that asks user number of students in a class and their names....

    Write a C++ program that asks user number of students in a class and their names. Number of students are limited to 100 maximum. Then, it will ask for 3 test scores of each student. The program will calculate the average of test scores for each student and display with their names. Then, it will sort the averages in descending order and display the sorted list with students’ names and ranking. Follow the Steps Below Save the project as A4_StudentRanking_yourname....

  • Using Java, write a program that teachers can use to enter and calculate grades of individual...

    Using Java, write a program that teachers can use to enter and calculate grades of individual students by utilizing an array, Scanner object, casting, and the print method. First, let the user choose the size for the integer array by using a Scanner object. The integer array will hold individual assignment grades of a fictional student. Next, use a loop to populate the integer array with individual grades. Make sure each individual grade entered by the user fills just one...

  • Your assignment is to write a grade book for a teacher. The teacher has a text file, which includ...

    Your assignment is to write a grade book for a teacher. The teacher has a text file, which includes student's names, and students test grades. There are four test scores for each student. Here is an example of such a file: Count: 5 Sally 78.0 84.0 79.0 86.0 Rachel 68.0 76.0 87.0 76.0 Melba 87.0 78.0 98.0 88.0 Grace 76.0 67.0 89.0 0.0 Lisa 68.0 76.0 65.0 87.0 The first line of the file will indicate the number of students...

  • (JAVA) Write a program that maintains student test scores in a two-dimesnional array, with the students...

    (JAVA) Write a program that maintains student test scores in a two-dimesnional array, with the students identified by rows and test scores identified by columns. Ask the user for the number of students and for the number of tests (which will be the size of the two-dimensional array). Populate the array with user input (with numbers in {0, 100} for test scores). Assume that a score >= 60 is a pass for the below. Then, write methods for: Computing the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT