Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For this assignment, you will create a new Netbeans project using the following

ID: 3820352 • Letter: F

Question

For this assignment, you will create a new Netbeans project using the following format LastNameFirstName-Homework6 and follow all instructions as given for each part of the assignment. Turn-in Instructions: Once finished, zip your project directory (which should result in a zip file named LastNameFirstName-Homework6.zip) and turn in via blackboard by the due date. No late homeworks will be accepted since the solution will appear on the deadline! Class Grading Simulation: we will be simulating test scores and homework scores for students, curving the individual test scores, determining if we need to offer extra credit, and reporting final averages for all students. We will be simulating students by using three arrays for 100 students, The first array holds their name (1 per student) The second array will hold their homework scores (6 per student) The third array will hold their exam scores (3 per student) Initialize the Arrays using the following instructions: The name array should be initialized using random first names and random last names in the format LastName, FirstName (like we did in class) The homework score array should be initialized using random integers between 60 and 100 for each student The test score array should be initialized using random numbers between 60 and 100 For each exam, determine if there needs to be a curve and do something about it if necessary. A curve is necessary if the average of the scores for that exam is below 75. If a curve is necessary, add the curve to the test scores and report the curve (if no curve, necessary report that as well) Determine if there needs to be homework extra-credit offered. Extra credit is necessary if and only if the average of all non-zero homeworks for all students is less than 75 If extra-credit is necessary, determine how much (75-average)*2 and offer it. You should assume that only some people will do it, so add to everyone's last homework a random amount of extra credit between 0 and (75-average)*2. o If extra-credit was necessary, report how much was offered, otherwise report none was necessary. Report the results of the simulated class! Calculate the final grade for each student using the grading of this class (15% for exam1, 25% for exam2, 30% for exam3) and 30% for the homework average o Report the final score for each student on its own line similar to: LastName, FirstName: SCORE o Print a blank line and then report the frequency (percentage using %) of each final grade in the class. Name your file: ClassSimulation.java

Explanation / Answer

PROGRAM CODE:

import java.util.Random;

public class ClassSimulation {

   static String firstNames[] = {"James", "Peter", "Mike", "Alicia", "Leena", "Divya", "Sherlock", "Miranda", "Julio", "Dilan"};
   static String lastNames[] = {"Holland", "Reynolds", "Sharma", "Holmes", "Rayland", "Watson", "Lee", "Ray", "Lolly", "Sprouse"};
  
   public static void main(String[] args) {
      
       Random random = new Random();
       String names[] = new String[100];
       int homeworkScores[][] = new int[100][6];
       int examScores[][] = new int[100][3];
       double homeAvg = 0;
       int exam1HighestScore = 0;
       int exam2HighestScore = 0;
       int exam3HighestScore = 0;
       int exam1Curve, exam2Curve, exam3Curve;
       double exam1Avg = 0.0;
       double exam2Avg = 0.0;
       double exam3Avg = 0.0;
      
       //Initializing all the arrays
       for(int i=0; i<100; i++)
       {
           names[i] = lastNames[random.nextInt(10)] + ", " + firstNames[random.nextInt(10)];
           for(int j=0; j<6; j++)
               homeworkScores[i][j] = random.nextInt(41) + 60;
           for(int j=0; j<3; j++)
               examScores[i][j] = random.nextInt(41) + 60;
       }
      
       //Determining curve for each exam
       //Exam 1 - determining the highest score
       exam1HighestScore = examScores[0][0];
       for(int i=0; i<100; i++)
       {
           exam1Avg += examScores[i][0];
           if(exam1HighestScore<examScores[i][0])
               exam1HighestScore = examScores[i][0];
       }
       exam1Avg = exam1Avg/100.0;
      
       if(exam1Avg <75)
       {
          
           exam1Curve = 100 - exam1HighestScore;
           System.out.println("Curve of " + exam1Curve + " was added for exam 1");
           for(int i=0; i<100; i++)
           {
               examScores[i][0] += exam1Curve;
           }
       }
      
       //Exam 1 - determining the highest score
       exam2HighestScore = examScores[0][1];
       for(int i=0; i<100; i++)
       {
           exam2Avg += examScores[i][1];
           if(exam2HighestScore<examScores[i][1])
               exam2HighestScore = examScores[i][1];
       }
       exam2Avg = exam2Avg/100.0;
      
       if(exam2Avg <75)
       {
           exam2Curve = 100 - exam2HighestScore;
           System.out.println("Curve of " + exam2Curve + " was added for exam 1");
           for(int i=0; i<100; i++)
           {
               examScores[i][1] += exam2Curve;
           }
       }
      
       //Exam 1 - determining the highest score
       exam3HighestScore = examScores[0][2];
       for(int i=0; i<100; i++)
       {
           exam3Avg += examScores[i][2];
           if(exam3HighestScore<examScores[i][2])
               exam3HighestScore = examScores[i][2];
       }
       exam3Avg = exam3Avg/100.0;
      
       if(exam3Avg <75)
       {
           exam3Curve = 100 - exam3HighestScore;
           System.out.println("Curve of " + exam3Curve + " was added for exam 1");
           for(int i=0; i<100; i++)
           {
               examScores[i][2] += exam3Curve;
           }
       }
      
       //determining the average for homeworks
       for(int i=0; i<100; i++)
       {
           homeAvg += homeworkScores[i][0];
           homeAvg += homeworkScores[i][1];
           homeAvg += homeworkScores[i][2];
           homeAvg += homeworkScores[i][3];
           homeAvg += homeworkScores[i][4];
           homeAvg += homeworkScores[i][5];
       }
       homeAvg = homeAvg/600.0;
      
       if(homeAvg<75)
       {
          
           for(int i=0; i<100; i++)
           {
               int extraCredit = (75 - (int)homeAvg)*2;
               System.out.println("An extra credit of " + extraCredit + " was added for " + names[i]);
               homeworkScores[i][5] += random.nextInt();
           }
       }
      
       for(int i=0; i<100; i++)
       {
           double score = (examScores[i][0]*15)/100.0 + (examScores[i][1]*25)/100.0 +(examScores[i][2]*30)/100.0;
           double homeAverage = homeworkScores[i][0] + homeworkScores[i][1] + homeworkScores[i][2] + homeworkScores[i][3] + homeworkScores[i][4] + homeworkScores[i][5];
           homeAverage = homeAverage/6;
           score += homeAverage*30/100.0;
           System.out.println(names[i] + ": " + score);
       }
   }

}

OUTPUT:

Rayland, Peter: 72.9
Watson, Mike: 85.45
Lolly, Dilan: 85.80000000000001
Lolly, Leena: 82.05
Sprouse, Miranda: 75.75
Ray, Dilan: 80.8
Watson, Sherlock: 78.44999999999999
Reynolds, Peter: 88.6
Reynolds, Divya: 86.6
Lolly, Divya: 81.3
Sharma, Sherlock: 77.14999999999999
Holmes, Julio: 89.6
Watson, Miranda: 79.15
Holmes, Mike: 85.25
Lee, Mike: 76.55
Lolly, Dilan: 71.1
Lee, Leena: 84.75
Holmes, Leena: 79.45
Sprouse, Julio: 80.7
Holland, Peter: 80.35
Ray, Peter: 80.89999999999999
Sharma, Sherlock: 82.5
Lee, James: 81.15
Watson, Julio: 82.0
Holland, Mike: 80.0
Holland, Sherlock: 78.85
Rayland, Alicia: 72.7
Sprouse, Leena: 82.1
Sprouse, Alicia: 79.95
Watson, Peter: 69.45
Lee, Julio: 78.55000000000001
Reynolds, Leena: 76.55
Reynolds, Alicia: 73.64999999999999
Rayland, Mike: 84.4
Sharma, Julio: 80.15
Lee, Peter: 70.7
Lolly, Alicia: 86.0
Ray, Dilan: 89.55
Watson, Peter: 75.3
Holmes, Divya: 78.69999999999999
Lolly, Leena: 89.3
Sharma, Alicia: 79.15
Reynolds, Julio: 83.1
Rayland, Miranda: 81.75
Sharma, Alicia: 88.14999999999999
Rayland, Alicia: 72.45
Holmes, Mike: 83.05000000000001
Lolly, Divya: 82.55
Holland, Dilan: 74.1
Watson, Sherlock: 75.80000000000001
Ray, Divya: 77.35
Rayland, Miranda: 79.4
Ray, Miranda: 82.55
Sprouse, Alicia: 84.2
Sprouse, Julio: 88.4
Lolly, Divya: 73.95
Rayland, Leena: 81.65
Reynolds, Divya: 84.3
Lee, Julio: 71.8
Sharma, Sherlock: 87.85
Holmes, Dilan: 78.05000000000001
Sharma, Julio: 78.85
Sharma, James: 91.2
Reynolds, Dilan: 79.75
Sprouse, Julio: 80.4
Lolly, Peter: 73.45
Lee, Miranda: 80.85
Ray, Divya: 72.45
Sharma, Peter: 79.45
Sprouse, Mike: 70.8
Holland, James: 81.75
Lolly, Alicia: 74.05
Sprouse, Sherlock: 72.95
Sharma, Sherlock: 87.1
Watson, Miranda: 77.44999999999999
Sprouse, Alicia: 85.6
Lolly, Peter: 69.69999999999999
Holmes, James: 77.7
Sprouse, Leena: 83.35
Watson, Peter: 79.75
Ray, Divya: 73.3
Lolly, Alicia: 83.35
Watson, Dilan: 85.69999999999999
Holland, Peter: 79.65
Ray, Mike: 75.85
Lolly, Leena: 90.35000000000001
Reynolds, Julio: 75.6
Rayland, Miranda: 87.05000000000001
Sprouse, James: 69.5
Rayland, Peter: 86.75
Sharma, Sherlock: 85.80000000000001
Sprouse, Divya: 79.85
Watson, Alicia: 83.2
Ray, Divya: 77.2
Holmes, James: 82.4
Reynolds, Leena: 92.85000000000001
Lolly, Sherlock: 82.15
Lolly, Mike: 78.1
Ray, Leena: 80.64999999999999
Sharma, Sherlock: 71.05

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote