Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create Client Code using MyArray and Course class: //MyArray class: public class MyArray { //variables Object[] myArray; int numElements; final int defCap = 10; int

image text in transcribedCreate Client Code using MyArray and Course class:

//MyArray class:

public class MyArray { //variables Object[] myArray; int numElements; final int defCap = 10; int origCap;

//default constructor public MyArray() { origCap = 10; myArray = new Object[defCap]; numElements = 0; }

//constructor public MyArray(int size) { myArray = new Object[size]; this.origCap = size; this.numElements = 0; } //method size to return numElements public int size(){ return numElements; } //method add() to append item to MyArray so that it is in the location right after what was the last element. public boolean add(T item){ if(numElements==origCap) expand(); myArray[numElements] = item; numElements++; return true; } //add item to MyArray in location loc. public boolean add(int loc, T item){ if(loc>numElements || locloc; i--){ myArray[i] = myArray[i-1]; } myArray[loc] = item; numElements++; return true; }

//method to allocate a new larger array. private void expand() { // expand the original size origCap = myArray.length+origCap; // create new array Object[] newArray = new Object[origCap]; //copy myArray to newArray for(int i=0; i=numElements || loc=numElements || index=numElements || loc

@Override public String toString() { String s = "ARRAY: "; for(int i=0; i

//Course class:

class Course { String code; String title; String section; String dept; String semester; String earnedGrade; int credits;

Course(String courseNumber, String courseName, String sectionNum, String dp, String Semester, String grade, int Credits) { code=courseNumber; title=courseName; section=sectionNum; dept=dp; semester=Semester; earnedGrade=grade; credits=Credits; } @Override public String toString() { return "Code: "+code+ " Title: "+title+ " Section: "+section+ " Dept: "+dept+ " Semester: "+ semester + " Earned Grade: "+earnedGrade+ " Credits: "+credits; } boolean equals(Course course) { if (course==null || !(course instanceof Course)) { return false; } Course Class= (Course)course; return (code.equals(class.courseNumber) && section.equals(class.sectionNum) && semester.equals(Class.Semester)); } String earnedGrade() { return earnedGrade; } int Credits() { return credits; } }

In the client/demo code you will read a transcript from a file, print the transcript, and calculate and print the number of credits and GPA. Then you will add and drop current semester courses from the keyboard, and print the transcript again. 1. Create a MyArray of Course objects. 2. Read the student name, student number, and completed courses from the file transcript.txt. The file has student name on the first line, student number on the second line, and then the courses, with each field on a separate line, in the following order: course number, course name, section, department, semester (Fall, Spring, Winter, or Summer and year), grade, credits. For each course read the fields, create a Course object, and add to the MyArray of Courses. 3. Print the student name and student number, then print all completed courses. 4. Calculate and print the total credits earned. 5. Calculate and print the GPA. This table shows the points earned for each grade. grade points A 4.0 A- B+ 3.7 3.5 3 B B- 2.7 C+ 2.5 2.0 D 1.0 F. 0 Calculate the grade points for a course by multiplying the points earned by the number of credits. Then calculate the GPA, by adding the points earned for all courses and dividing by the total number of credits completed. 6. Prompt the user to enter four courses being taken during the current semester. Use an empty String for the grade. 7. Prompt the user to drop one of the courses. Prompt for the course number, department, and semester. Find the course in the MyArray and remove 8. Print the student name and number and all of the courses in the MyArray. In the client/demo code you will read a transcript from a file, print the transcript, and calculate and print the number of credits and GPA. Then you will add and drop current semester courses from the keyboard, and print the transcript again. 1. Create a MyArray of Course objects. 2. Read the student name, student number, and completed courses from the file transcript.txt. The file has student name on the first line, student number on the second line, and then the courses, with each field on a separate line, in the following order: course number, course name, section, department, semester (Fall, Spring, Winter, or Summer and year), grade, credits. For each course read the fields, create a Course object, and add to the MyArray of Courses. 3. Print the student name and student number, then print all completed courses. 4. Calculate and print the total credits earned. 5. Calculate and print the GPA. This table shows the points earned for each grade. grade points A 4.0 A- B+ 3.7 3.5 3 B B- 2.7 C+ 2.5 2.0 D 1.0 F. 0 Calculate the grade points for a course by multiplying the points earned by the number of credits. Then calculate the GPA, by adding the points earned for all courses and dividing by the total number of credits completed. 6. Prompt the user to enter four courses being taken during the current semester. Use an empty String for the grade. 7. Prompt the user to drop one of the courses. Prompt for the course number, department, and semester. Find the course in the MyArray and remove 8. Print the student name and number and all of the courses in the MyArray

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

More Books

Students also viewed these Databases questions

Question

Find dy/dx if x = te, y = 2t2 +1

Answered: 1 week ago

Question

2. How were various roles filled?

Answered: 1 week ago

Question

2. What process will you put in place to address conflicts?

Answered: 1 week ago