Question

can someone please help me with my homework question for java array

Instructions from your teacher. Below two-dimensional array representing the grades for students (4) exams (5) taken for the

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

public class Main
{
   public static void main(String[] args)
   {
   //2D array declaration and initialization
double grades[][] =
{
{75.20, 84.60, 72.50, 85.60, 78.00},
{65.20, 99.70, 82.00, 90.00, 89.00},
{95.00, 89.10, 77.00, 69.40, 77.00},
{95.20, 84.50, 74.50, 88.00, 90.00}
};
  
//1D array declaration and initialization
String students[] = {"Mark", "Tom", "Susan", "Ray"};
     
   for(int i=0; i<4; i++)
{
   double totalGrade = 0;
  
   //calculate the total grade
   for(int j=0; j<5; j++)
   {
   totalGrade = totalGrade + grades[i][j];
   }
  
   //calculate the average grade
   double avgGrade = totalGrade / 5;
  
   //display the result
   System.out.println("\n\nStudent Name: "+ students[i]);
   System.out.printf("Total grades: %.2f", totalGrade);
   System.out.printf("\nAverage grade: %.2f", avgGrade);
   }
   }
}

OUTPUT:

Student Name: Mark
Total grades: 395.90
Average grade: 79.18

Student Name: Tom
Total grades: 425.90
Average grade: 85.18

Student Name: Susan
Total grades: 407.50
Average grade: 81.50

Student Name: Ray
Total grades: 432.20
Average grade: 86.44

Add a comment
Know the answer?
Add Answer to:
can someone please help me with my homework question for java array Instructions from your teacher....
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
  • b 3.01 [3 points - Due by Jul 231] Due: -- submit Instructions from your teacher:...

    b 3.01 [3 points - Due by Jul 231] Due: -- submit Instructions from your teacher: Below two-dimensional array representing the grades for student's (4) exams (5) taken for the course- grades - {{75.20, 84.60, 72.50, 85.60, 78.00}, {65.20, 99.70, 82.00, 90.00, 89.00}, {95.00, 89.10, 77.00, 69.40, 77.00}, {95.20, 84.50, 74.50, 88.00, 90.00} }; students - { "Mark", "Tom", "Susan", "Ray" }; Find each student's total grade and average grade. Print it (System.out) to the console/screen.

  • this is a java course class. Please, I need full an accurate answer. Labeled steps of...

    this is a java course class. Please, I need full an accurate answer. Labeled steps of the solution that comply in addition to the question's parts {A and B}, also comply with: (Create another file to test the class and output to the screen, not an output file) please, DO NOT COPY others' solutions. I need a real worked answer that works when I try it on my computer. Thanks in advance. Write the definition of the class Tests such...

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