I am working on a class assignment where I am to write a program that
calculates the final grade for the class based on grades for the
individual assignments. I have pasted my working code below.
However, the instructions for the assignment said for the application
to "read the input values from instance variable declarations." I am
doubtful that I implemented the program correctly, and would
appreciate suggestions on a simpler and/or more appropriate way to
write it.
// The "Calculator1" class.
public class Calculator1
{
final static int EXAM = 60; //final exam grade
final static int OWL = 90; //OWL homework average
final static int [] quiz = {100, 78, 75, 60, 90, 50, 50};
final static int [] mt = {84, 78}; //midterm grades
public static void main (String [] vars)
{
Calculator1 calc = new Calculator1 ();
double points = (calc.midterms (mt) * 20) + (calc.quizzes
(quiz) * 30) + (EXAM * 35) + (OWL * 15);
double temp1 = points / 10;
int temp2 = (int) temp1;
double average = temp2 / 10.0;
System.out.println ("Your grade is " + average);
} // main method
public double midterms (int [] mt)
{
double mtAve = (mt [0] + mt [1]) / 2;
return mtAve;
} // midterm average method
public double quizzes (int [] quiz) //avg. of 6 highest quizzes
{
int small = 0;
int total = 0;
for (int i = 0 ; i < quiz.length ; i++)
{
if (quiz [i] < quiz [small])
small = i;
}
for (int i = 0 ; i < quiz.length ; i++)
{
if (i != small)
total += quiz [i];
}
double qAve = (total / 6);
return qAve;
} // quiz average method
} // Calculator1 class