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

  • SEARCH
  • Home
  • 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 7788761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:05:12+00:00 2026-06-01T21:05:12+00:00

This is homework. I’m trying to work with arrays and this is the first

  • 0

This is homework. I’m trying to work with arrays and this is the first project working with them. My book shows all kinds of examples but the way they code the examples doesn’t do any justice to what the assignment calls for.

I am trying to write a program that asks a user to enter students into the system. The program first asks how many you will enter then it will prompt you for the first name, last name, and score.

What I am trying to accomplish with this section of code is to ask the user how many students they will enter. The line of code that says

    getStudentCount();

is a method that collects that information and then returns studentCount

I tried to code this to where the length of the array is going to be the number the user enters but it’s not working so I wanted to ask for guidance. Ideally if this works and the user enters 3 then you will be prompted to enter the information 3 times. If the user enters 0 then the program doesn’t ask you anything.

    public static void main(String[] args)
{

    System.out.println("Welcome to the Student Scores Application.");

    int studentCount = 1;

    getStudentCount();
    studentCount = sc.nextInt();

    String [] students = new String[studentCount];
    for (int i = 0; i < students.length; i++)
    {

        Student s = new Student();
        String firstName = getString("Enter first name: ");
        s.setFirstName(firstName);

        String lastName = getString("Enter last name: ");
        s.setLastName(lastName);

        int score = getScore("Enter score: ");
        s.setScore(score);


    }

}

Everything I had in the program worked up until I tried to code

    String [] students = new String[studentCount];
    for (int i = 0; i < students.length; i++)

which tells me there is something wrong with the way I am doing this.

Also the assignment asks that I store the information in the array. I’m not clear on how to call it or I guess store it…. I have another class with setters and getters. Is that enough to store it? How would I call it?
Again this is homework so any guidance is appreciated.
Thanks!

  • 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-06-01T21:05:13+00:00Added an answer on June 1, 2026 at 9:05 pm

    Well that’s at least a homework example that shows some work on the part of the askee (and nicely written), so here’s some help:

    You set the studentCount to 1 and then call getStudentcount(), but never assigns the return value to your variable, hence the variable stays 1 (though you’re overwriting it afterwards with sc.nextInt() which is probably not what you want if you already have a nice method for it). The fix is just to assign the return value of your method to the variable [1]

    [1] Yes I know I shouldn’t answer homework questions completely, but I really saw no way whatsoever to answer that only partially – proposals welcome though 🙂

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

Sidebar

Related Questions

First of all this is homework. I have been trying to get rid of
First off, this is homework. I'm trying to read a 5 digit number into
I'm working on this homework that's kind of confusing me... I am provided with
I am working on this homework assignment and I am stuck on what I
(This is no homework and no work issue. It's just my personal interest/occupation and
Background / Disclaimer First of all, please feel free to skip this entirely if
This is homework, just so that's mentioned. I have project called AdventCalendar, which is
I was trying to solve this homework assignment but was unable to come up
First, I'll admit this is homework but it has been around six years since
So, first off, this is homework, albeit not mine. It's my brother-in-law's. He asked

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.