Write additional code that conforms to this outline

Assignment Help JAVA Programming
Reference no: EM131591380

This homework document consists of 5 pages. Carefully read the entire document before you start coding. This homework is intended to be a revision of concepts taught in CSE 114. It combines several topics and skills that a student of CSE 214 is already expected to have mastered, including arrays, basic OOP concepts in Java such as extending existing classes and exception handling, and File I/O.

Overview

The "big picture" of this assignment is to have three parallel arrays that provide information about a list of students. These arrays contain their names, their GPAs, and their student IDs. All the data is provided in a single tab-separated file with each line formatted as follows:
name<ONE-OR-MORE-TABS>gpa<ONE-OR-MORE-TABS>student id

Your submitted assignment should be able to read such a file and fill the three arrays with the appropriate data, print out all the data, and filter out students whose GPA is below a certain user-provided threshold.

The outline of the code is already given to you. Your task is to write additional code that conforms to this outline. You must add your own code wherever indicated. Three (incomplete) classes and one small sample input data file are provided:

- Main
- InputDataHandler
- input.txt

Keep in mind that you are not allowed to modify the given code (including .java file names).

Your homework submission will be tested assuming that the given code structure is unchanged, so any unwarranted change may lead to test cases failing to run properly.

Tasks

The "main" class
The main class that runs the whole code is "Main.java". This class is responsible for reading the input file, creating the object that maintains the three arrays, and then uses this object to print information and filter students based on GPA.

The path to the input file must be provided as the value of the constant INPUT FILE PATH first.

The code for Main.java is incomplete, and your first task is complete it. After reading the data from the input file, the program asks the user to provide a GPA value as a cutoff for enrollment. Completing this is a part of your assignment. This is VERY important, because without this, the next part of the program cannot be tested! The incomplete Main.java is shown next.

Main.java
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException; import java.net.URL;

/** @author Ritwik Banerjee */ public class Main {
private static final String INPUT_FILE_PATH = "/path/to/input/file";

public static void main(String[] args)
throws URISyntaxException, IOException, InputFileFormatException { File inFile = new File(INPUT_FILE_PATH);
InputDataHandler handler = new InputDataHandler(inFile); handler.printAllDetails();
System.out.print("Enter the GPA cutoff for the course: ");
// TODO: add your code to read user input handler.filter(cutoff); handler.printAllDetails();
}
}

Task Goals
- The cutoff GPA provided by the user should be deemed invalid if it is lower than 1.0 or higher than 4.0. It should, of course, be deemed invalid if it anything other than a double.
- If the user enters an invalid cutoff GPA value, your code should print a meaningful error message and ask for the user input again.

Processing input data and the "InputDataHandler" class
This is where all the data handling and processing happens. Your job here is to write
- the constructor for this class,
- the printAllDetails() method,
- the deleteStudent(int) method, and
- a Java documentation in the same style as shown in the provided code to explain what could go wrong in the filter(double) method (i.e., why it may fail to remove students whose GPA is below the cutoff provided by the user).
All three tasks must adhere to the documentation provided in the code.
InputDataHandler.java
import java.io.BufferedReader; import java.io.File;
import java.io.FileReader; import java.io.IOException;

/** @author Ritwik Banerjee */ class InputDataHandler {

private String[] nameArray; private Double[] gpaArray; private Integer[] idArray;
// TODO: write Javadoc explaining why this approach of filtering may fail void filter(double cutoff) {
for (int i = 0; i < gpaArray.length; i++) { if (gpaArray[i] < cutoff)
deleteStudent(i);
}
}

/**
* The only constructor for this class. It takes an input file as its argument,
* and populates the three arrays such that the n'th line's data is stored in
* the (n-1)'th index of all three arrays. It throws an <tt>IOException</tt>
* if the <tt>inputFile</tt> is not a file (e.g., it's a directory, symbolic link,
* etc.). It also throws an <tt>InputFileFormatException</tt> if the input file
* contains lines that are not properly formatted or if it contains a line with
* an invalid value for the GPA.
*
* @param inputFile the input file with 3 columns of tab-separated data in each line.
* @throws IOException if there is any problem reading the input file.
* @throws InputFileFormatException if there is any formatting problem in the
* input file.
*/
InputDataHandler(File inputFile) throws IOException, InputFileFormatException {
// TODO: add your code
}

/**
* Prints out the details of all the students in this class.
* This must be in the following format:
* <br>
* Name : <i>name of student</i><br>
* GPA : <i>GPA of student</i><br>
* Student ID: <i>ID of student</i><br>
* There must also be a one-line gap between two students.
*/
void printAllDetails() {
// TODO: add your code
}

/**
* This method removes all the information about a student whose information
* is stored at the specified index (in all three arrays). It also ensures
* that after the removal, all three arrays in the <tt>InputDataHandler</tt>
* class have their size reduced by one, and subsequent student information

* is shifted to the left by one.
*
* @param index the specified index where data is removed. private void deleteStudent(int index) {
// TODO: add your code
}
}

Writing your own exception
The InputFileFormatException class is something you will have to write yourself. It must be a direct subclass of java.lang.Exception, and have a constructor that allows an error message to be taken as its argument.

Reference no: EM131591380

Questions Cloud

Define restatement of the controversy : you will write your abstract. The following components are requirements of the assignment
Explain the reasons for the disparities : Describe the experience for those outcomes in Kerala and suggest reasons for why they are similar or different from the rest of India.
Professional nursing practice environment : Describe physical factors that make for a healthy environment. Discuss the hallmarks of a healthy, professional nursing practice environment.
Employing the capital asset pricing model : What is the estimated cost of common? equity, employing the Capital Asset Pricing Model? (CAPM)?
Write additional code that conforms to this outline : It combines several topics and skills that a student of CSE 214 is already expected to have mastered, including arrays, basic OOP concepts in Java
Prepare a cash budget for january and february : Enright Company expects to have a cash balance of $64,760 on January 1, 2014. Required - Prepare a cash budget for January and February
What is the net present value of the factory : The cost of capital is 8%. What is the net present value (NPV) of the factory?
Calculate the profitability index : A project has initial investment of $196,600 and will generate 5 annual cash flows of $59,500. Assume cost of capital of 14%. Calculate the profitability index?
Describe the process of recruitment : Describe the process of recruitment. Discuss the practice of conducting regular employee satisfaction surveys as a recruitment approach.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd