CSE205 Object Oriented Programming and Data Structures Programming Project 2 1 Project Instructions • Create a folder named p2. • Copy all your .java source code files to p2. Do not copy the .class...

1 answer below »
Programming Project Instructions is attached for guide and to be adhere strictly


CSE205 Object Oriented Programming and Data Structures Programming Project 2 1 Project Instructions • Create a folder named p2. • Copy all your .java source code files to p2. Do not copy the .class files or any testing files. • Compress the p2 folder creating a zip archive file named p2.zip. • Upload p2.zip to the Programming Project 2 (P2) submission page in Gradescope. • The project deadline may be found in the Course Schedule section of the Syllabus. • Consult the Syllabus for the late submission and academic integrity policies. 2 Learning Objectives 1. Read UML class diagrams and convert the diagram into Java classes [Ch. 12; Module 2: Video Lectures 1-3]. 2. Utilize dependency, aggregation, inheritance, and composition relationships. [Ch. 12; Module 2: Video Lectures 1-3]. 3. Properly use the public, private, and protected accessibility modifiers [Ch. 9; Module 2: Video Lectures 5-8]. 4. Write Java code to override methods [Ch. 9; Module 2: Video Lectures 9-12]. 5. Recognize when inheritance is present among classes in an OOD. [Chs. 9, 12; Module 2: Video Lectures 14-20]. 6. Design and implement classes using inheritance. [Chs. 9, 12: Module 2: Video Lectures 1-26]. 7. To write Java code to implement polymorphism in a class inheritance hierarchy. [Ch. 9; Module 3: Lectures 1-10]. 8. To implement a Java interface [Ch. 10; Module 3: Video Lectures 5-10]. 3 Background Springfield State University is located in sunny beautiful Springfield, but strangely, no Springfield resident knows which state they live in. Anyway, at SSU there are two categories of students: on-campus students and online students. On-cam- pus students are categorized as residents (R) or nonresidents (N) depending on whether they reside within state or they reside out of state. The base tuition for on-campus students is $7575 for residents and $14,875 for non-residents. Some on- campus students, enrolled in certain pre-professional programs, e.g, law, dentistry, pharmacy, are charged an additional program fee which varies depending on the program. An on-campus students may enroll for up to 18 credit hours at the base rate but for each credit hour exceeding 18, they pay an additional fee of $475 for each credit hour over 18. Online students are neither residents nor non-residents. Rather, their tuition is computed as the number of credit hours for which they are enrolled multiplied by the online credit hour rate which is $950 per credit hours. Furthermore, some online students enrolled in certain degree programs pay an online technology fee of $75 per semester. 4 Software Requirements The software requirements for this project are: 1. Student information for Springfield State is stored in a text file named p2-students.txt. There is one student record per line, where the format of a student record for an on-campus student is: C id last-name first-name residency program-fee credits where: C Identifies the student as an on-campus student. id The student identifier number. A string of 13 digits. last-name The student's last name. A contiguous string of characters. first-name The student's first name. A contiguous string of characters. residency R if the student is a resident, N if the student is a non-resident. program-fee A program fee, which may be zero. credits The number of credit hours for which the student is enrolled. The format of a student record for an online student is: O id last-name first-name tech-fee credits © Kevin R. Burger :: Arizona State University :: Rev 024221 :: It is a copyright violation to publish this document w/o permission Page 1 CSE205 Object Oriented Programming and Data Structures Programming Project 2 where O identifies the student as an online student, and id, last-name, first-name, and credits are the same as for an on-campus student. The tech-fee field is T if the student is to be assessed the technology fee or - if the stu- dent is not assessed the technology fee. Here is an example p2-students.txt file, which you can use for testing your pro- gram. Sample p2-students.txt C 8230123345450 Simons Jenny R 0 12 C 3873472785863 Cartman Eric N 750 18 C 4834324308675 McCormick Kenny R 0 20 O 1384349045225 Broflovski Kyle - 6 O 5627238253456 Marsh Stan T 3 2. The program shall read the contents of p2-students.txt and calculate the tuition for each student. 3. The program shall write the tuition results to an output file named p2-tuition.txt formatted thusly: id last-name first-name tuition id last-name first-name tuition ... where id is the student identifier number, last-name and first-name are the student's name, and tuition is the computed tuition for the student. id shall be output left-justified in a field of width 16, last-name shall be output left-justified in a field of width 20, first-name shall be output left-justified in a field of width 15, and tuition shall be output right-justified in a field of width 8 with two digits after the decimal point. For the sample input file, this is the output file: Sample p2-tuition.txt 1384349045225 Broflovski Kyle 5700.00 3873472785863 Cartman Eric 15625.00 4834324308675 McCormick Kenny 8525.00 5627238253456 Marsh Stan 2925.00 8230123345450 Simons Jenny 7575.00 4. The records in the output file shall be sorted in ascending order by id. 5. If the input file p2-students.txt cannot be opened for reading (probably because it does not exist) then output an error message to the output window, close any open files, and then terminate the program, e.g., Sorry, could not open 'p2-students.txt' for reading. Stopping. 6. If the output file p2-tuition.txt cannot be opened for writing, then output an error message to the output window, close any open files, and then terminate the program, e.g., Sorry, could not open 'p2-tuition.txt' for writing. Stopping. 5 Software Design You are free to create your own software design for the program or you may follow our software design described here. Refer to and study the UML class diagram in §5.7. 5.1 Main Class The main class is named Main and a template for Main.java is included in the project zip archive. The Main class shall contain the main() method which shall simply instantiate an object of the Main class and call run() on that object. Com- plete the code in Main.java by reading the UML class diagram, the comments, and implementing the pseudocode. 5.2 TuitionConstants Class A class named TuitionConstants class is included in the project zip archive. This class declares several public static con- stants that are used in other classes. The constants are derived from the discussion in §3 Background. © Kevin R. Burger :: Arizona State University :: Rev 024221 :: It is a copyright violation to publish this document w/o permission Page 2 CSE205 Object Oriented Programming and Data Structures Programming Project 2 5.3 Sorter Class We shall discuss sorting algorithms later in Module 5, so this code may not make perfect sense at this time. Because I do not know which sorting algorithms you may have been exposed to in CSE110 or other non-ASU introduction to program - ming classes, I have provided all of the sorting code for you. If you are interested, Sorter uses the insertion sort algorithm which is not very efficient for large lists but is efficient enough for small lists such as ours. The Sorter class contains a public class method insertionSort() that can be called to sort a list of ArrayList. When sorting Students we need to be able to compare one Student A to another Student B to determine if A is less than or greater than B. Since we are sorting by student id, we have the abstract Student class implement the java.lang. Comparable interface and we define Student A to be less than Student B if the mId field of A is less than the mId field of B. This is how we sort the ArrayList list by student identifier. java.lang.Comparable is a generic interface in the Java Class Library (it requires a type parameter T to be specified when the interface is implemented) that declares one method: int compareTo(T obj) where T represents a class type and obj is an object of the class T. The method returns a negative integer if this T (the object on which the method is invoked) is less than obj, zero if this T and obj are equal, or a positive integer if this T is greater than obj. To make abstract class Student implement the Comparable interface, we write: public abstract class Student implements Comparable { ... } Since Student implements Comparable, whenever compareTo() is called in Sorter.keepMoving() to compare two Student objects, either OnCampusStudent.compareTo() or OnlineStudent.compareTo() will be polymorphically called. Also, study the comments for the keepMoving() method where I have used and discussed how to use the ternary opera- tor ?: (which is inherited from the C language). There is a nice explanation of ?: on this web page. 5.4 Student Class There is a template for the Student class is in the project zip archive. The Student class is an abstract class that imple- ments the java.lang.Comparable interface (see §5.3): public abstract class Student implements Comparable { ... } A Student object contains five instance variables (I preface my instance data members with a lowercase m for member): mCredits Number of credit hours the student is enrolled for. mFirstName The student's first name. mId The student's id number. mLastName The student's last name. mTuititon The student's computed tuition. Note that these data members are common to both OnCampusStudents and OnlineStudents. Most of the Student instance methods should be straightforward to implement (the majority of them are simple accessor/mutator methods) so we will only mention the two that are not
Answered 2 days AfterJan 28, 2022

Answer To: CSE205 Object Oriented Programming and Data Structures Programming Project 2 1 Project Instructions...

Aditya answered on Jan 30 2022
101 Votes
C 8230123345450 Simons Jenny R 0 12
C 3873472785863 Cartman Eric N 750 18
C 4834324308675 McCormic
k Kenny R 0 20
O 1384349045225 Broflovski Kyle - 6
O 5627238253456 Marsh Stan T 3
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here