Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7584307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:53:20+00:00 2026-05-30T18:53:20+00:00

ok so this is the assignment that I’m working on: Implement a class Student

  • 0

ok so this is the assignment that I’m working on:

“Implement a class Student (you may use the one you created for lab and add on to it). In addition to any other attributes that the class already has, the student object will have a total quiz score. Be sure to write a complete class (i.e. proper attributes, constructor, accessors and mutators).

Other methods needed are: addQuiz(int score), showStudentInfo(), and getAverageScore(). Note that in order to calculate average, the class needs to know the number of quizzes.
The driver/tester class will create three (3) student objects. Each student object’s method will be called five times to add five (5) quiz grades.

I recommend that you use Random class to generate the quiz values, instead of hard-coding them.Then the driver calls Student’s method to display the students’ name, all five quiz grades, and the average score of the quizzes.”

I have a basic idea of what needs to be done but I’m just unsure on some of the methods. For example the “getAverageScore” method is the one that I’m having trouble with. Also do I even need the get and set methods for age name and major if I’m am just initializing them at the beginning of the tester program? Any help on what needs to be added or fixed with my class is greatly appreciated. Here is the code that I have so far:

import java.util.Random;

public class Student
{
  private int Age;
  private String Name;
  private String Major;
  private int Score;

  public Student(String n, int a, String m)
  {
    Name = n;
    Age = a;
    Major = m;
  }

  public String showStudentinfo()
  { return (Name + " " + Age + " " + Major + "\n");
  }

  public int addQuiz()
  { Score = randomNumbers.nextInt(101);
    return Score;
  }

  public int getAverageScore()
  { 
  }

  //setter methods
  public void setAge(int a)
  { Age = a;
  }
  public void setName(String n)
  { Name = n;
  }
  public void setMajor(String m)
  { Major = m;
  }

  //getter methods
  public int getAge()
  { return Age;
  }
  public String getName()
  { return Name;
  }
  public String getMajor()
  { return Major;
  }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T18:53:21+00:00Added an answer on May 30, 2026 at 6:53 pm

    You need to store the quiz grades somewhere. Your professor said there would be more than one. Above the ‘Student’ constructor, add either an Array of size 5 or an ArrayList. I will use an Array for this, so:

    private int[] scores = new int[5];
    

    Then in your method that gets the scores, add them to the Array with a Loop:

    public void addQuiz() { 
        for(int i = 0; i < 5; i++){ //Loops through and adds 5 scores
        int score = randomNumbers.nextInt(101);
        scores[i] = score;
        }
    }
    

    Then you should be able to calculate the average of the scores by adding the grades together and dividing them by 5:

    public int getAverageScore() {
        int totalScore = scores[0] + scores[1] + scores[2] + scores[3] + scores[4];
        int avgScore = totalScore / 5;
        return avgScore;
    }
    

    I have not actually tested this code, and I am a beginner myself, but hopefully this puts you on the right track. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a class assignment that must be done using a dynamically created array
I am learning SQL and DB design for a college class. One assignment that
I'm currently working on a program (for fun, this is not an assignment) that
I am working on an assignment that uses a base class bankAccount and two
I've been working on a school assignment that makes pretty heavy use of vectors,
I have this school assignment that I've been working on and am totally stumped
I am working on an assignment that asks me to implement an AVL tree.
I have an assignment that my teacher has told us to use this in
For this assignment I had to create my own string class. I initially wrote
I've been working on this assignment, where I need to read in records and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.