Using Problem Solving with C++ (9th Edition) Chapter 2 to chapter 8 Can anyone h
ID: 3860802 • Letter: U
Question
Using Problem Solving with C++ (9th Edition) Chapter 2 to chapter 8
Can anyone help me to solve this problem? This is my FINAL PROJECT!!!
PLEASE FOLLOW ALL THE STEPS.
Problem 1-
1.You will read grades from a file called gradebook.txt
2.The number of grade may vary – They are not always 10
3.You will read everything using String then convert grades to int
4.Create two two-dimensional arrays one for first name, last name and one for grades.
5.Count to see how many grades you have.
6.Create two more arrays one for average for each student and one for average for each test.
7.Create three SVG files to display
a.Average of each student
b.Average of each test
c.Sorted test average of course
8.Each bar should be different color preferably green for the highest and red for the lowest with decreeing green and increasing red as we go from highest to lowest.
9.You should be able to demonstrate your project and answer every question about your project.
10. Everything has to be in functions with proper documentation – Check chapter two for proper documentation.
Explanation / Answer
import java.util.*;
import java.io.*;
import java.text.*;
public class
public static void main(String[]args) throws
{
inputFile = new ("scores.txt");
data = new (inputFile);
averages = new ("#.#");
int students = data.nextInt();
int assignments = data.nextInt();
double gradebook[][] = new double [students + 1][assignments + 1];
for (int i=0; i<students; i++)
{
for (int j=0; j<assignments; j++)
{
gradebook[i][j] = data.nextDouble();
}
}
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;
}
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;
}
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.