Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

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:
namegpastudent 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 IOException
* if the inputFile is not a file (e.g., it's a directory, symbolic link,
* etc.). It also throws an InputFileFormatException 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:
*

* Name : name of student

* GPA : GPA of student

* Student ID: ID of student

* 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 InputDataHandler
* 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.

Java, Programming

  • Category:- Java
  • Reference No.:- M92400093
  • Price:- $10

Priced at Now at $10, Verified Solution

Have any Question?


Related Questions in Java

Simple order processing systemquestion given the classes

Simple Order Processing System Question: Given the classes Ship (with getter and setter), Speedboat, and SpeedboatTest. Answer the following questions: Refine the whole application (all classes) and create Abstract class ...

Question slideshows or carousels are very popular in

Question : Slideshows (or carousels) are very popular in websites. They allow web developers to display news or images on the website in limited space. In this code challenge, you are required to complete the JavaScript ...

Answer the following question whats the difference public

Answer the following Question : What's the difference public inheritance and private inheritance? What can derived classes inherit from base classes? What cannot be inherited from base classes?

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Assessment -java program using array of Assessment -JAVA Program using array of objects

Assessment -JAVA Program using array of objects Objectives This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details For this assignment, you are required to develop a Windowed G ...

Assignment - method in our madnessthe emphasis for this

Assignment - "Method in our Madness" The emphasis for this assignment is methods with parameters. In preparation for this assignment, create a folder called Assign_3 for the DrJava projects for the assignment. A Cityscap ...

Chatbotscreate a small networked chat application that is

Chatbots Create a small, networked chat application that is populated by bots. Introduction On an old server park, filled with applications from the early days of the internet, a few servers still run one of the earliest ...

Solving 2nd degree equationsbull write the following java

Solving 2nd degree equations • Write the following Java methods • boolean real-sols(double a, double b, double c): it returns true if the 2nd degree equation ax2 + bx + c has real solutions • double solution1(double a, d ...

Can someone help me please with those question1what is the

Can someone help me please with those question 1:what is the best data type for student id datatime,currency,number,decimal 2:which relationshipis preferable? one to one,one to many,many to many 3:if you add table A's pr ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As