Answered Essay: 0000 Verizon 10:56 AM a bbprod.hwcc.edu In this project, you will input student data from a file – create student objects add student objects to an array –

.0000 Verizon 10:56 AM a bbprod.hwcc.edu In this project, you will input student data from a file - create student objects add student objects to an array - write the student object data to standard output Download the input text file studentinput3.txt. This file contains four sets of data. Each set of data includes four lines that correspond to one students data. The first line is the students first and last name, the second line is the students id number, the third is the students year and the fourth contains the students major Modify your RunStudent program from project 2 to create a Student array, read the sets of data, create a student object, add the object to the array, and print the array. There are many different ways to do this, but we will do i in the most basic way The first question is: do we know how many sets of data are in the file? If we do, and if this number is not likely to change, a for loop and an array are fine to use. An array has a set size that cannot be changed. So, if we know we will only have 10 students, we can create a Student array of size 10 and use a for loop to traverse the input file. If we have a file, but do not know how many students are contained in the file, an array might not be our best bet. An ArrayList has room for 10 elements by default, but can grow and shrink. An ArrayList has methods to add elements that do the work for us if the list gets too large for the current size. But deep down inside, an ArrayList contains an array. For this project, we know that we will only have four students, so we will create an array of size 4. Since we have only four students, this means we will have four sets of data. This makes reading from the file casy: a for loop that executes four times and reads the four lines of data during each loop iteration. Reading the data from the file can be tricky It would be best to get this part of the program working first before you proceed to the rest of the program. It is always important to make sure the data structures appropriately contain the data. The last step will be to create a method in the RunStudent class that writes the content of the array to standard output.
media%2F5ba%2F5bafef70-d921-4d19-8bee-f6
media%2Fbff%2Fbff93418-708a-4987-8742-40
media%2F928%2F928db129-3d47-4023-b2d0-52

0000 Verizon 10:56 AM a bbprod.hwcc.edu In this project, you will input student data from a file – create student objects add student objects to an array – write the student object data to standard output Download the input text file studentinput3.txt. This file contains four sets of data. Each set of data includes four lines that correspond to one student’s data. The first line is the student’s first and last name, the second line is the student’s id number, the third is the student’s year and the fourth contains the student’s major Modify your RunStudent program from project 2 to create a Student array, read the sets of data, create a student object, add the object to the array, and print the array. There are many different ways to do this, but we will do i in the most basic way The first question is: do we know how many sets of data are in the file? If we do, and if this number is not likely to change, a for loop and an array are fine to use. An array has a set size that cannot be changed. So, if we know we will only have 10 students, we can create a Student array of size 10 and use a for loop to traverse the input file. If we have a file, but do not know how many students are contained in the file, an array might not be our best bet. An ArrayList has room for 10 elements by default, but can grow and shrink. An ArrayList has methods to add elements that do the work for us if the list gets too large for the current size. But deep down inside, an ArrayList contains an array. For this project, we know that we will only have four students, so we will create an array of size 4. Since we have only four students, this means we will have four sets of data. This makes reading from the file casy: a for loop that executes four times and reads the four lines of data during each loop iteration. Reading the data from the file can be tricky It would be best to get this part of the program working first before you proceed to the rest of the program. It is always important to make sure the data structures appropriately contain the data. The last step will be to create a method in the RunStudent class that writes the content of the array to standard output.

Expert Answer

 

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

/**
*
* @author Sam
*/
public class Student {
private String name;
private String idNum;
private String year;
private String major;

public Student(String name, String idNum, String year, String major) {
this.name = name;
this.idNum = idNum;
this.year = year;
this.major = major;
}

public String getName() {
return name;
}

public String getIdNum() {
return idNum;
}

public String getYear() {
return year;
}

public String getMajor() {
return major;
}

@Override
public String toString() {
return “Student name: ” + name + “nID Number: ” + idNum
+ “nYear: ” + year + “nMajor: ” + major + ‘}’;
}

}

class RunStudent {
public static void main(String[] args) throws IOException{
String name;
String idNum;
String year;
String major;
int i = 0; //index
BufferedReader br = new BufferedReader(new FileReader(“studentInput3.txt”));
Student[] students = new Student[4];
while ((name = br.readLine())!= null) {
idNum = br.readLine();
year = br.readLine();
major = br.readLine();

if (year.equalsIgnoreCase(“F”))
year = “Freshman”;
else if (year.equalsIgnoreCase(“O”))
year = “Sophomore”;
else if (year.equalsIgnoreCase(“S”))
year = “Senior”;
else if (year.equalsIgnoreCase(“J”))
year = “Junior”;

students[i++] = new Student(name, idNum, year, major);
}
br.close();

printStudentArray(students);
}

public static void printStudentArray(Student[] a) {
for (Student s:a)
System.out.println(“n———————————–n”
+ s.toString()
+ “n———————————–n”);
}
}

This code is sufficent for

Buy Essay
Calculate your paper price
Pages (550 words)
Approximate price: -

Help Me Write My Essay - Reasons:

Best Online Essay Writing Service

We strive to give our customers the best online essay writing experience. We Make sure essays are submitted on time and all the instructions are followed.

Our Writers are Experienced and Professional

Our essay writing service is founded on professional writers who are on stand by to help you any time.

Free Revision Fo all Essays

Sometimes you may require our writers to add on a point to make your essay as customised as possible, we will give you unlimited times to do this. And we will do it for free.

Timely Essay(s)

We understand the frustrations that comes with late essays and our writers are extra careful to not violate this term. Our support team is always engauging our writers to help you have your essay ahead of time.

Customised Essays &100% Confidential

Our Online writing Service has zero torelance for plagiarised papers. We have plagiarism checking tool that generate plagiarism reports just to make sure you are satisfied.

24/7 Customer Support

Our agents are ready to help you around the clock. Please feel free to reach out and enquire about anything.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

HOW OUR ONLINE ESSAY WRITING SERVICE WORKS

Let us write that nagging essay.

STEP 1

Submit Your Essay/Homework Instructions

By clicking on the "PLACE ORDER" button, tell us your requires. Be precise for an accurate customised essay. You may also upload any reading materials where applicable.

STEP 2

Pick A & Writer

Our ordering form will provide you with a list of writers and their feedbacks. At step 2, its time select a writer. Our online agents are on stand by to help you just in case.

STEP 3

Editing (OUR PART)

At this stage, our editor will go through your essay and make sure your writer did meet all the instructions.

STEP 4

Receive your Paper

After Editing, your paper will be sent to you via email.

× How can I help you?