CS210 Programming Assignment #8 Solution

$35.00 $24.00

(50 points) This assignment focuses on reading input file, array structures, arrylist and classes. You have to use the student class as shown below and ArrayList as we discussed at the class. Be sure to include a short comment at the beginning of your program as well as a short comment for each method describing…

You’ll get a: . zip file solution

 

 
Categorys:

Description

5/5 – (2 votes)

(50 points) This assignment focuses on reading input file, array structures, arrylist and classes. You have to use the student class as shown below and ArrayList as we discussed at the class. Be sure to include a short comment at the beginning of your program as well as a short comment for each method describing what it does. For this assignment you are limited to the language features in Chapters 1-8 shown in lecture or the textbook.

 

Write a Java program that outputs a list of students from the given data file.  Download the data file (student.txt) from our web site to the same folder as your program. You have to input the name of the data file from keyboard. You have to use input.hasNext()or input.hasNextInt() or input.hasNextDouble()with while loop when your program reads tokens from the file. We are

assuming that you don’t know how many lines are in the data file. The file contains student name followed

by gender and age. Your program should output each gender, total number of students, and each student’s

id, name and age belonging in the gender on screen. For example, if your data file contains the following

data:

 

1 John m 18

2 William m 22

3 Susan f 21

4 Jack m 19

5 Jennifer f 18

Your program should produce the following output on the screen (not the text file): What is the file name? student.dat

 

Female students: 2

ID Name Age

—————–

3 Susan    21

5 Jennifer 18

 

Male students: 3

ID Name Age

—————–

1 John      18

2 William 22

4 Jack       19

 

 

// student class

class student { String id; String name; String gender; int age;

}

 

1