Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Java, Write a method that asks the user for the file location and returns the user input as File if and only if the

In Java, Write a method that asks the user for the file location and returns the user input as File if and only if the file exists and is readable. Otherwise, the method should be indefinitely executed. Read the file in, one student at a time by utilizing the following.

Generate a class Student for the individual rows in the text file,i.e.,a class that holds the required items for each student. Include constructors for the scenarios that you can encounter. Perform the following basic string manipulations as you process the entries:

The Logon id should alwaysbe all low-caps

Random numbers that are not given in the text file should be replaced with the string0

If any other entries in a row are missing(or if there are too many entries), the entire rows hould

be discarded and the user informed about the row that was discarded and its original line number in the text file

Hint: you need the String.split(",") function here to break the string apart into another array of string, check/modify values, and finally reassemble the checked values again into a new string.

Generate an aggregated class for all the student entries(rows) in the CSVfile. Include a constructor as well as a method addStudent which adds a Student object to the aggregated class. Include a toString method that returns all students as a single String.

Hint: You will need an ArrayList of type Student.

Generatepublicmethodsintheaggregatedclassto

1. CalculatethesumofallrandomnumbersgetSum,returnslong 2. CountthestudententriesgetStudentCount,returnsint 3. Getthemaximumrandomnumberrow(arrayindex)getMaxIndex,returnsint

4. Gettheminimumrandomnumberrow(arrayindex)getMinIndex,returnsint

5. Return a specific index i from the array get Index,returns Student

Write a method each that determines the following values from the cleaned array input: [4]

1. Sum of all random numbers(returnslong) 2. Average of all random numbers(returnsdouble) 3. Row in the cleaned array with maximum random number(returnslong) 4. Row in the cleaned array with the minimum random number(returnslong)

Hint: you need the String.split(",") function here to break the string apart into another array of string, then convert the String to a long value using Long.parseLong(String s).

6. Print the following items to standard output:

1. All entries that make up your aggregated class instance

2. Sumofallrandomnumbers 3. Countofentries 4. Averageofallrandomnumbers

5. Maximumrandomnumber

6. Minimumrandomnumber

This is the contents of the csv file: andrew,Comma,comma1aj,83559, Andrew,Karpenter,karpe1aj,966796,15.7 Brandon,Turnip,turni1bw,715855, Brenda,Miso,miso1b,747747, Chris,Shoe,shie1c,123784, David,Cool,Cool1d,200100, Django,,uncha1d,830700, Erik,Tata,,400500, Jakob,Doolittle,dooli1j,555777, Thomas,Jefferson,jeff1t,951753, Kaya,Coffee,coffee1k,789456, Owen,Wilson,wilso1o,456123, Test,student,seeli1p_s,, ,demo,demo1s,58578, 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Internals A Deep Dive Into How Distributed Data Systems Work

Authors: Alex Petrov

1st Edition

1492040347, 978-1492040347

More Books

Students also viewed these Databases questions