wood burning stoves 2.0*
The moose likes JavaFX and the fly likes Java Programming Help? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JavaFX
Bookmark "Java Programming Help?" Watch "Java Programming Help?" New topic

Java Programming Help?

Johny Do

Joined: Oct 07, 2009
Posts: 1
I hope its ok if I post questions about my error problems.

Here is my messed up program.
I am wondering if anyone could help me correct it by explaining and posting a correct script for the flawed coding sections.
prompt will be posted after my code.
** With my code I dont know how to fix it so that my average score becomes 95.8333 rather than 97.
public class Student
private int quiz;
private double quizNum;
private String name;

public Student(String n)


name = n;


public String getName()
return name;

public double getAverageScore()
return quizNum;

public void addQuiz(double scores)
quizNum = scores;
scores = (quiz + quiz + quiz)/3;



public class StudentRunner
public static void main(String[] args)
Student s = new Student("I Fail at Java");
System.out.println("Name: "+s.getName());
System.out.println("Quiz average is " +s.getAverageScore());


Implement a class Student. A student is composed of a name, a total of all the quiz
scores they have taken, and the number of quizzes taken. Supply an appropriate
constructor and methods getName(), addQuiz(double score), and
getAverageScore(). Your client program should contain the following code:
Student s = new Student("Mary Ott");
System.out.println("Name: " + s.getName());
System.out.println("Quiz average is " + s.getAverageScore());

Philippe Lhoste

Joined: Oct 23, 2009
Posts: 28
You are in a JavaFX section, not a Java one...

But being a kind soul, I will help a bit. Look at your method:

quizNum is equals to the last given value (last call of the method), you sum three times a variable that never changes, and at the end, modify a parameter which is lost on the next line.
I agree. Here's the link: http://aspose.com/file-tools
subject: Java Programming Help?
Similar Threads
Array returning last value entered
Confused with file read
grade program
Compile error
Help with toString message