Java programming

1

Don't use plagiarized sources. Get Your Custom Essay on
Java programming
Just from $13/Page
Order Essay

CIS 265 Data Structures and Algorithms

Assignment 5, 100 points

Due: 12:25pm, Mar. 10, 2021

I. General Description

In this assignment, you will create a Java program to read undergraduate and graduate students from an input

file, and write them in reverse order to an output file.

1. The input file name and the output file name are passed in as the first and second arguments at command
line, respectively. For example, assume your package name is FuAssign5 and your main class name is

FuAssignment5, and your executable files are in “C:\Users\2734848\eclipse-workspace\CIS 265

Assignments\bin”. The following command line will read from a local file “students.txt” and write to a

local file “students_reversed.txt”:
C:\Users\2734848\eclipse-workspace\CIS 265 Assignments\bin > java FuAssign5.FuAssignment5
students.txt students_reversed.txt

2. You need to specify the command line arguments if you use jGrasp or Eclipes. I will show you on jGrasp
on Wed.

3. The parameter String[] args in the main method contains the command line arguments, where args[0]
contains the first argument. For example, in the previous command, args[0] contains students.txt, and

args[1] contains students_reversed.txt.

4. If the program is run with incorrect number of arguments, your program must print an error message and
exit. The error message must show correct format to run your program, e.g., “Usage:

FuAssign5.FuAssignment5 input_file output_file” where FuAssign5 is the package and FuAssignment5 is

the main class.

5. Each line in the input file represents a student. There are 5 fields in each line: name, id, gpa, “graduate” or
“undergraduate”, isTransfer (for undergraduate) or college (for graduate). The fields are separated by

comma, “,”. For example, the input file students.txt file may contain:

Michelle Chang,200224,3.3,graduate,Cleveland State University
Tayer Smoke,249843,2.4,undergraduate,false
David Jones,265334,2.7,undergraduate,true
Abby Wasch,294830,3.6,graduate,West Virginia

6. The program will read the lines and create undergraduate students or graduate students accordingly. The

students are added to an ArrayList.

7. The program then writes the list of students in reserve order to the output file.
8. Given the previous input file students.txt, the output file, students_reserved.txt, will be:

Abby Wasch,294830,3.6,graduate,West Virginia
David Jones,265334,2.7,undergraduate,true
Tayer Smoke,249843,2.4,undergraduate,false
Michelle Chang,200224,3.3,graduate,Cleveland State University

II. Implementation Requirements

The program must implement a main class and three student classes (Student, UndergradStudent, GradStudent).

• You may reuse the code from previous assignments.

2

• However, the Student class must be declared as an abstract class now. It must also have an overloaded
printStudent(PrintWriter output) method. The method will write student’s information to the output file

using the PrintWriter output.

• Accordingly, the UnderGradStudent and GradStudent classes must also have an overloaded
printStudent(PrintWriter output) method. They must use the superclass’ method to write student’s

information. The UnderGradStudent’s printStudent(PrintWriter output) writes “undergraduate” and

isTransfer after that. The GradStudent’s printStudent(PrintWriter output) writes “graduate” and college

after that.

• The UML class diagram should be as follows.

• All classes must be in the same package. The package name must start with your last name. For example, if
your last name is “Fu”, your package name must start with “Fu” such as “FuCIS265AS3”, “FuAS3”, etc.

• Your main class file name must start with your last name. For example, if your last name is “Fu”, your main
class file name must start with “Fu” such as FuAssignment5.java.

• Since I/O exceptions are checked exceptions, your program must handle exceptions. You may use the
try/catch or throw IOException. To throw exceptions, you declare it as:

public static void main(String[] args) throws IOException {

• You must create an ArrayList of Students in the main class:
import java.util.ArrayList;
ArrayList students = new ArrayList<>();

The ArrayList students will store all Student objects created, both undergraduate students and graduate
students.

• The Student class must have a constructor that takes a name, an id, and a gpa, to create a Student object.

• The UndergradStudent class must have a constructor that takes a name, an id, a gpa, and a transfer status to
create an UndergradStudent object. The constructor must call the Student’s constructor using super.

• The GradStudent class should must a constructor that takes a name, an id, a gpa, and a college to create a
GradStudent object. The constructor must call the Student’s constructor using super.

• The Student class must have a public method printStudent(PrintWriter output) that writes the student’s name,
id, and gpa to the PrintWriter output.

Student

-name: String

-id: int

-gpa: float

+Student()

+Student(name,id,gpa)

+printStudent():void

+getID():int

+printStudent(PrintWriter output):void

UndegradStudent

-boolean: isTransfer

+UndergradStudent(name,id,gpa,isTransfer)

+printStudent():void
+printStudent(PrintWriter output):void

GradStudent

-college:String

+GradStudent(name,id,gpa,college)

+printStudent():void
+printStudent(PrintWriter output):void

3

• The UndergradStudent class must override the printStudent(PrintWriter output) method. It must write the
student’s name, id, gpa, and transfer status to the PrintWriter output. It should call the Student’s

printStudent(PrintWriter

output) to write student’s name, id, and gpa.

• The gradStudent class must override the printStudent(PrintWriter output) method. It must write the student’s
name, id, gpa, and college to the PrintWriter output. It should call the Student’s printStudent(PrintWriter

output) to write student’s name, id, and gpa.

• Your program must use dynamic binding to invoke the correction printStudent(PrintWriter output) method.

• Your program must close both input and output files after they are done.

• You can assume that input file has the correct format. You will earn bonus points for handling incorrect
input formats.

III. Submission

This is an individual assignment. Each student needs to submit the source code files of the Java program on

Blackboard.

1. Put all you Java files in a folder. Please name the folder after your package name, for example,
FuAssign5. Compress the folder into a .zip file and submit the .zip file.

2. You need to only submit the source code, i.e., the Java files.
3. You may submit multiple time. Your most recent submission before the deadline will be graded.

IV. Grading
1. A program that does not run will receive 0 point.
2. There is a 10-20 points deduction for each major error, e.g., missing a student in the output.
3. There is a 1-9 points deduction for each minor error, e.g., a spelling error in printed message.
4. A program that does not follow the guidelines will lose 1-10 points.
5. Any type of cheating is not tolerated. You may be asked to explain your program in person.

V. Bonus features (optional)

If a line in the input file has incorrect format, your program will print an error message with the line, skip the

line and continue. The following are possible formatting errors your program can handle:

1. (2 points) if the line does not have 5 fields;
2. (2 points) if the id is not an integer;
3. (2 points) if the gpa is not a double;
4. (2 points) if the 4th field is not “undergraduate” or “graduate”;
5. (2 points) if the 5th field for an undergraduate student is not true or false.

For example, for the following lines in the input file,

Sam Jackson,215.22,3.9,graduate,Ohio State University
Sam Jackson,215443,22af,graduate,Ohio State University
Sam Jackson,215443,3.9,graduate
Sam Jackson,215443,3.9,graduate,Ohio State University,cleavland
Sam Jackson,215443,3.9,nondegree,Ohio State University
Lady Gaga,230940,3.1,undergraduate,unknown

You program will print :

Invalid input: Sam Jackson,215.22,3.9,graduate,Ohio State University

4

Invalid input: Sam Jackson,215443,22af,graduate,Ohio State University
Invalid input: Sam Jackson,215443,3.9,graduate
Invalid input: Sam Jackson,215443,3.9,graduate,Ohio State University,cleavland
Invalid input: Sam Jackson,215443,3.9,nondegree,Ohio State University
Invalid input: Lady Gaga,230940,3.1,undergraduate,unknown

The incorrect lines will be ignored and not written to the output file. The correctly formatted lines should be

handled as usual.

What Will You Get?

We provide professional writing services to help you score straight A’s by submitting custom written assignments that mirror your guidelines.

Premium Quality

Get result-oriented writing and never worry about grades anymore. We follow the highest quality standards to make sure that you get perfect assignments.

Experienced Writers

Our writers have experience in dealing with papers of every educational level. You can surely rely on the expertise of our qualified professionals.

On-Time Delivery

Your deadline is our threshold for success and we take it very seriously. We make sure you receive your papers before your predefined time.

24/7 Customer Support

Someone from our customer support team is always here to respond to your questions. So, hit us up if you have got any ambiguity or concern.

Complete Confidentiality

Sit back and relax while we help you out with writing your papers. We have an ultimate policy for keeping your personal and order-related details a secret.

Authentic Sources

We assure you that your document will be thoroughly checked for plagiarism and grammatical errors as we use highly authentic and licit sources.

Moneyback Guarantee

Still reluctant about placing an order? Our 100% Moneyback Guarantee backs you up on rare occasions where you aren’t satisfied with the writing.

Order Tracking

You don’t have to wait for an update for hours; you can track the progress of your order any time you want. We share the status after each step.

image

Areas of Expertise

Although you can leverage our expertise for any writing task, we have a knack for creating flawless papers for the following document types.

Areas of Expertise

Although you can leverage our expertise for any writing task, we have a knack for creating flawless papers for the following document types.

image

Trusted Partner of 9650+ Students for Writing

From brainstorming your paper's outline to perfecting its grammar, we perform every step carefully to make your paper worthy of A grade.

Preferred Writer

Hire your preferred writer anytime. Simply specify if you want your preferred expert to write your paper and we’ll make that happen.

Grammar Check Report

Get an elaborate and authentic grammar check report with your work to have the grammar goodness sealed in your document.

One Page Summary

You can purchase this feature if you want our writers to sum up your paper in the form of a concise and well-articulated summary.

Plagiarism Report

You don’t have to worry about plagiarism anymore. Get a plagiarism report to certify the uniqueness of your work.

Free Features $66FREE

  • Most Qualified Writer $10FREE
  • Plagiarism Scan Report $10FREE
  • Unlimited Revisions $08FREE
  • Paper Formatting $05FREE
  • Cover Page $05FREE
  • Referencing & Bibliography $10FREE
  • Dedicated User Area $08FREE
  • 24/7 Order Tracking $05FREE
  • Periodic Email Alerts $05FREE
image

Our Services

Join us for the best experience while seeking writing assistance in your college life. A good grade is all you need to boost up your academic excellence and we are all about it.

  • On-time Delivery
  • 24/7 Order Tracking
  • Access to Authentic Sources
Academic Writing

We create perfect papers according to the guidelines.

Professional Editing

We seamlessly edit out errors from your papers.

Thorough Proofreading

We thoroughly read your final draft to identify errors.

image

Delegate Your Challenging Writing Tasks to Experienced Professionals

Work with ultimate peace of mind because we ensure that your academic work is our responsibility and your grades are a top concern for us!

Check Out Our Sample Work

Dedication. Quality. Commitment. Punctuality

Categories
All samples
Essay (any type)
Essay (any type)
The Value of a Nursing Degree
Undergrad. (yrs 3-4)
Nursing
2
View this sample

It May Not Be Much, but It’s Honest Work!

Here is what we have achieved so far. These numbers are evidence that we go the extra mile to make your college journey successful.

0+

Happy Clients

0+

Words Written This Week

0+

Ongoing Orders

0%

Customer Satisfaction Rate
image

Process as Fine as Brewed Coffee

We have the most intuitive and minimalistic process so that you can easily place an order. Just follow a few steps to unlock success.

See How We Helped 9000+ Students Achieve Success

image

We Analyze Your Problem and Offer Customized Writing

We understand your guidelines first before delivering any writing service. You can discuss your writing needs and we will have them evaluated by our dedicated team.

  • Clear elicitation of your requirements.
  • Customized writing as per your needs.

We Mirror Your Guidelines to Deliver Quality Services

We write your papers in a standardized way. We complete your work in such a way that it turns out to be a perfect description of your guidelines.

  • Proactive analysis of your writing.
  • Active communication to understand requirements.
image
image

We Handle Your Writing Tasks to Ensure Excellent Grades

We promise you excellent grades and academic excellence that you always longed for. Our writers stay in touch with you via email.

  • Thorough research and analysis for every order.
  • Deliverance of reliable writing service to improve your grades.
Place an Order Start Chat Now
image

Order your essay today and save 30% with the discount code Happy