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 8065343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:38:39+00:00 2026-06-05T11:38:39+00:00

I’m a total beginner with my first programming assignment in Java. For our programming

  • 0

I’m a total beginner with my first programming assignment in Java.
For our programming assignment, we will be given a .txt file of students like so:

My problem is: I have a specific class for turning the data from the file into variables to be used for a different class in printing it to the screen. However, I do not know of a good way to get the variables from the input file for the course numbers, since that number is not predetermined. The only way I can think of to iterate over that unknown amount is using a loop, but that would just overwrite my variables every time. Also, the teacher has requested that we not use any JCL classes (I don’t really know what this means.)

Sorry if I have done a poor job of explaining this, but I can’t think of a better way to conceptualize it. Let me know if I can clarify.

Edit:

public static void analyzeData()
{
    Scanner inputStream = null;

    try
    {
        inputStream = new Scanner(new FileInputStream("Programming Assignment 1 Data.txt"));
    }

    catch (FileNotFoundException e)
    {
        System.out.println("File Programming Assignment 1 Data.txt could not be found or opened.");
        System.exit(0);        
    }

    int numberOfStudents = inputStream.nextInt();
    int tuitionPerHour = inputStream.nextInt();
    String firstName = inputStream.next();
    String lastname = inputStream.next();
    String isTuitionPaid = inputStream.next();
    int numberOfCourses = inputStream.nextInt();
    String courseName = inputStream.next();
    String courseNumber = inputStream.next();
    int creditHours = inputStream.nextInt();
    String grade = inputStream.next();

To show the methods I am using now, I am just using a Scanner to read from the file and for Scanner inputStream, I am using nextInt() or next() to get variables from the file. Obviously this will not work when I do not know exactly how many classes each student will have.

  • 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-05T11:38:40+00:00Added an answer on June 5, 2026 at 11:38 am
    1. Create a Class called Student

    2. Inside the class use instance variable like

      String firstName;

      String lastname;

      Boolean isTuitionPaid; // Boolean cause isPaid will be true or false

      String[] courses;

      int creditHours;

      String grade;

    3. Create a constructor of this class which takes the following arguments in its parameter

      Student( String fName,String lName,Boolean istPaid,String[] course,int cHours,String gr)

    4. When you read the data of a student from a file, store it in the appropriate data type, as mentioned in the constructor, then create the Object of type Student

    5. After creating the Student object with the data, store it an appropriate Collection.
      ArrayList, Map, etc

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace

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.