Results 1 to 2 of 2
  1. #1
    ALH813 is offline Member
    Join Date
    Oct 2009
    Posts
    6
    Rep Power
    0

    Default Help with implement class programming assignment

    I need to store the number of quizzes taken so that the program will compute the average score. This is what I have:

    public class Student {

    private double totalscore;
    private String studentName;
    private double average;

    public Student(){
    totalscore = 0;
    average = totalscore/3;
    }

    public Student (String name){
    studentName = name;
    }


    public void addQuiz(int score){
    totalscore = totalscore + score;
    }

    public void AverageScore(){
    average = totalscore/3;
    }


    public double getAverageScore(){
    return average;
    }

    public double getTotalScore(){
    return totalscore;
    }

    public String getName(){
    return studentName;
    }
    (this is the Student Class)


    public class StudentTester {

    /**
    * @param args
    */
    public static void main(String[] args) {
    // TODO Auto-generated method stub

    Student Amanda = new Student("Amanda Hunter");
    Amanda.addQuiz(90);
    Amanda.addQuiz(95);
    Amanda.addQuiz(87);
    Amanda.getTotalScore();
    Amanda.getName();
    Amanda.getAverageScore();
    System.out.println(Amanda.getName());
    System.out.println(Amanda.getTotalScore());
    System.out.println(Amanda.getAverageScore());
    System.out.println();

    Student Brian = new Student("Brian Wyman");
    Brian.addQuiz(100);
    Brian.addQuiz(90);
    Brian.addQuiz(97);
    Brian.getTotalScore();
    Brian.getName();
    Brian.getAverageScore();
    System.out.println(Brian.getName());
    System.out.println(Brian.getTotalScore());
    System.out.println(Brian.getAverageScore());
    System.out.println();

    Student Ben = new Student("Ben Hunter");
    Ben.addQuiz(85);
    Ben.addQuiz(96);
    Ben.addQuiz(92);
    Ben.getTotalScore();
    Ben.getName();
    Ben.getAverageScore();
    System.out.println(Ben.getName());
    System.out.println(Ben.getTotalScore());
    System.out.println(Ben.getAverageScore());
    System.out.println();
    }
    (this is the StudentTester Class)

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    This is a duplicate or Cross-post and thus will be locked.

    Crosspost: need help with implementing class

    OP, please choose the one single best forum to post your question so as not to divide the discussion. If you have any cross-posts of this same question in other fora, you should also post the links here. Thank you for your cooperation.

Similar Threads

  1. Replies: 1
    Last Post: 05-31-2009, 11:57 PM
  2. Replies: 1
    Last Post: 05-31-2009, 03:17 PM
  3. Replies: 16
    Last Post: 05-28-2009, 04:41 PM
  4. Replies: 14
    Last Post: 05-28-2009, 06:44 AM
  5. Implement a class Employee-Help due tmrw!
    By Britt7 in forum New To Java
    Replies: 3
    Last Post: 10-27-2008, 02:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •