Write a java program that calculates the homework assignment grade points (a 100
ID: 3604881 • Letter: W
Question
Write a java program that calculates the homework assignment grade points (a 100 points scale) (java programming)
Rule #1:
The score calculation is based on:
1. all problems are attempted (40 percent) before the due date, and
2. 75% or more are correct (40 percent proportionally to the attempted ones),
Rule #2:
Assignment submitted after the scheduled due date will drop 1/2 of points
The program should prompt use to input the following data and calculate and output the result for each student:
Prompt for data:
1 Number of problems attempted on or before due date
2. Number of correct problems among (1) above
3. Number of problems attempted after due date
4. Number of correct problems among (3) above
5. Number of un-attempted problems
6. Number of “Programming Projects” submitted
7. Number of “Programming Projects” not submitted
Explanation / Answer
import java.util.*;
import java.io.*;
import java.text.*;
public class StudentGradebookScores {
public static void main(String[]args) throws IOException {
File inputFile = new File("scores.txt");
Scanner data = new Scanner(inputFile);
DecimalFormat averages = new DecimalFormat("#.#");
int students = data.nextInt();
int assignments = data.nextInt();
double gradebook[][] = new double [students + 1][assignments + 1];
//putting the scores into the array
for (int i=0; i<students; i++) { //rows
for (int j=0; j<assignments; j++) { //coloums
gradebook[i][j] = data.nextDouble();
}
}
//calculating the average assignment score for each student (coloums)
for (int i=0; i<students; i++) {
double studentTotal = 0;
for (int j=0; j<assignments; j++) {
studentTotal = studentTotal + gradebook[i][j];
}
gradebook[i][assignments] = studentTotal/assignments;
}
//calculating the average score of each assigment for all students (rows)
for (int j=0; j<assignments; j++) {
double assignmentTotal = 0;
for (int i=0; i<students; i++) {
assignmentTotal = assignmentTotal + gradebook[i][j];
}
gradebook[students][j] = assignmentTotal/students;
}
//printing the gradebook
System.out.print(" Assignment #: ");
for (int j=0; j<assignments; j++) {
System.out.print((j+1) + " ");
}
System.out.println("Avg");
for (int i=0; i<students; i++) {
System.out.print("Student #" + (i+1) + ": ");
for (int j=0; j<assignments; j++) {
System.out.print(gradebook[i][j] + " ");
}
System.out.println(averages.format(gradebook[i][assignments]));
}
System.out.print("Average ");
for (int j=0; j<assignments; j++) {
System.out.print(averages.format(gradebook[students][j]) + " ");
}
System.out.println();
double overallAvg = 0;
for (int i=0; i<students; i++) {
overallAvg = overallAvg + gradebook[i][assignments];
}
System.out.println(" Overall Average: " + averages.format(overallAvg/students));
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.