This is a homework assignment and is also my first Java program. I wrote a StudentAverage class, now I want to test the class methods, but when I write my tester program, the IDE is telling me that I cannot declare my main static. I am using Eclipse as my IDE.
Since this is a homework assignment and I am still learning Java, I would also appreciate some guidance as to what I am doing wrong.
Here is my code:
/**
*Program: StudentAverage, Calculate the student average quizzes taken
* @author: Jose Mazorra
* Date: July 11, 2013
* Class: CIS406
*/
/**
A student who is taking quizzes.
*/
public class StudentAverage
{
//Instances variables
private String name;
private double quizScores;
private double numOfQuizzesTaken;
/**
Constructs a student with a given name.
@param n the name
*/
public StudentAverage(String stuName)
{
name = (stuName);
}
/**
Gets the name of this student.
@return the name
*/
public String getName()
{
return name;
}
/**
Adds a quiz score.
@param score the score to add
*/
public void addQuiz(int score)
{
numOfQuizzesTaken++;
quizScores = quizScores + score;
}
/**
Gets the sum of all quiz scores.
@return the total score
*/
public double getTotalScore()
{
return quizScores;
}
/**Returns the average of all quiz taken
* by the student
* @return average score
*/
public double getAverageScore(){
double avgScore;
avgScore = (quizScores / numOfQuizzesTaken);
return avgScore;
}
public class StudentAverageTester{
public static void main(String[] args){
StudentAverage student = new StudentAverage()
student.name("Jose");
student.numOfQuizzesTaken(10);
student.quizScores(400);
double avg = student.avgScore();
System.out.println(name);
System.out.println(avg);
System.out.println("Expected 40");
}
}
}
publicclasses in the same file?publickeyword in the second class or move it to its own seperate file