2dGPA
package csa_2d;
/**
* @author dan
*
* Create a program and submit in schoology.
* Requirements
* use 2 d arrays to store your grades
* You should have 7 school classes/periods
* within those classes each should have 4 formative grades and 3 summative grades
* for a total of 49 data points.
* i.e. period 1 formative grade of 85
* Calculate weighted average score by class then you can also then calculate average score for all classes.
*
*/
public class csa_2d {
public static void main(String[] args) {
// TODO Auto-generated method stub
int[][] fgrds = { { 85, 40, 90, 75 }, { 87, 92, 75, 40 }, { 92, 100, 81, 75 }, { 87, 92, 75, 40 },
{ 72, 94, 99, 40 }, { 92, 100, 81, 75 }, { 83, 84, 95, 71 } };
int sum = 0;
double favg = 0;
double fpercent = .2;
double spercent = .8;
int fgrades = 4;
int classes = 7;
for (int i = 0; i < classes; i++) {
sum = 0;
for (int j = 0; j < fgrades; j++)
sum += fgrds[i][j];
favg = sum / fgrades;
// System.out.println("The sum of row " + (i + 1) + ": " + sum);
System.out.println("The formative avg of class " + (i + 1) + ": " + favg);
}
int[][] sgrds = { { 85, 65, 90 }, { 87, 92, 65 }, { 92, 100, 91 }, { 87, 92, 77 }, { 72, 94, 99 },
{ 92, 100, 81 }, { 83, 84, 95 } };
int ssum = 0;
double savg = 0;
int sgrades = 3;
int stotalpt = 0;
for (int i = 0; i < classes; i++) {
ssum = 0;
for (int j = 0; j < sgrades; j++)
ssum += sgrds[i][j];
savg = ssum / sgrades;
stotalpt = stotalpt + ssum;
System.out.println("The sum of row " + (i + 1) + ": " + stotalpt);
System.out.println("The summative avg of class " + (i + 1) + ": " + savg);
double avg_grade = (favg * fpercent) + (savg * spercent);
System.out.println("The avg of all classes " + avg_grade);
double gpa;
gpa = stotalpt/(sgrades)/classes;
double savgpts = stotalpt/sgrades;
System.out.println("The gpa of all classes " + savgpts);
System.out.println("The gpa of all classes " + gpa);
}
}
}