Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hey I need help with this assignment. This program needs to be done in Java Prog

ID: 3605935 • Letter: H

Question

Hey I need help with this assignment. This program needs to be done in Java Programming Language. Submit the Course.java and Student.java files as a single zipped file. Please I need all the help I can get. Thanks! The 5 files are linked in the link provided and is given as a zip file: http://www.filedropper.com/progivstuff

You will find a file (ProgramIV.zip) that contains 5 files - Course.java, Student.java, StudentDriver.java, CoursesTaken.txt, and CurrentCourses.txt. Course.java and Student.java both contain many unimplemented methods that you must implement. StudentDriver.java is already implemented and must not be changed in any way. CoursesTaken.txt and CurrentCourses.txt contain data that you must use to construct an ArrayList of courses that a student has already taken and an ArrayList of courses that a student is currently taking. A correct run of your program using this data is as follows:

Please enter the name of the file with the courses taken:

CoursesTaken.txt

Please enter the name of the file with the current courses:

CurrentCourses.txt

Course Designator: IT

Course Number: 210

Course Description: Introduction to Programming

Section: 2

Letter Grade: B

Course Designator: IT

Course Number: 214

Course Description: Introduction to Software Development

Section: 1

Letter Grade: A

Course Designator: IT

Course Number: 310

Course Description: Data Structures

Section: 1

Letter Grade: B

Course Designator: IT

Course Number: 414

Course Description: Advanced Object-Oriented Programming with Design Patterns

Section: 2

Letter Grade: C

Course Designator: IT

Course Number: 483

Course Description: Web Applications and User Interface Design

Section: 1

Letter Grade: A

Course Designator: IT

Course Number: 340

Course Description: Introduction to Database Systems

Section: 1

Letter Grade: B

id: 00001234

First Name: Joe

Last Name: Student

Major: Anthropology

Minor: Biology

Gpa: 3.17

Explanation / Answer

Hello, I have modified your code to work perfectly according to the requirements.

//Course.java

/**

A Course class that maintains course information

via the instance variables specified

*/

public class Course {

      String courseDesignator;

      String courseNumber;

      String courseDescription;

      int credits;

      String section;

      String letterGrade;

     

      /**

            Course constructor

      */

      public Course(String courseDesignator, String courseNumber,String courseDescription, int credits, String section, String letterGrade) {

           

            this.courseDesignator = courseDesignator;

            this.courseNumber = courseNumber;

            this.courseDescription=courseDescription;

            this.credits=credits;

            this.section=section;

            this.letterGrade=letterGrade;

           

      }

      public String getCourseDesignator() {

            return courseDesignator;

      }

      public void setCourseDesignator(String courseDesignator) {

            this.courseDesignator=courseDesignator;

      }    

     

      public String getCourseNumer() {

            return courseNumber;

      }

      public void setCourseNumber(String courseNumber) {

            this.courseNumber=courseNumber;

      }

     

      public String getCourseDescription() {

            return courseDescription;

      }

      public void setCourseDescription(String courseDescription) {

            this.courseDescription=courseDescription;

      }

     

      public int getCredits() {

            return credits;

      }

      public void setCredits(int credits) {

            this.credits=credits;

      }    

     

      public String getSection() {

            return section;

      }

      public void setSection(String section) {

            this.section=section;

      }    

     

      public String getLetterGrade() {

            return letterGrade;

      }

      public void setLetterGrade(String letterGrade) {

            this.letterGrade=letterGrade;

      }    

     

      public boolean equals(Object obj) {

            if(obj instanceof Course){

                  Course c=(Course) obj;

                  if(this.courseDesignator.equals(c.courseDesignator) && this.courseDescription.equals(c.courseDescription) && this.section.equals(c.section) && this.credits==c.credits && this.courseNumber.equals(c.getCourseNumer())){

                        return true;

                  }

            }

            return false;

      }    

     

      public String toString() {

            String str="Course Designator: "+courseDesignator;

            str+=" Course Number: "+courseNumber;

            str+=" Course Description: "+courseDescription;

            str+=" Section: "+section;

            str+=" Letter Grade: "+letterGrade;

            return str;

      }

}

//Student.java file

import java.util.ArrayList;

import java.text.DecimalFormat;

/**

A Student class that maintains course information

via the instance variables specified

*/

public class Student {

     

      private String id;

      private String firstName;

      private String lastName;

      private String major;

      private String minor;

      private ArrayList<Course> coursesTaken;

      private ArrayList<Course> currentSemesterCourses;

      private double gpa;

     

      /**

            Course constructor

      */

      public Student(String id, String firstName, String lastName, String major, String minor, ArrayList<Course> coursesTaken, ArrayList<Course> currentSemesterCourses) {

            this.id=id;

            this.firstName=firstName;

            this.lastName=lastName;

            this.major=major;

            this.minor=minor;

            this.coursesTaken=coursesTaken;

            this.currentSemesterCourses=currentSemesterCourses;

     

      }

     

/* This method calculates a student's gpa by iterating through the list of courses taken and obtaining the number of credits and the letter grades

      for each course. It uses the letterGradeConverter() method to give the numeric value for a given letter grade. E.g., if the letter

      grade is "A", it returns 4, etc.*/

      public double calculateGpa() {

            int total=0;

            for (Course c : coursesTaken) {

                  total=total+letterGradeConverter(c.getLetterGrade());

            }

            double avg=(double)total/coursesTaken.size(); /*finding the average gpa*/

            return avg;

      }

      /* Returns the numeric value for a letter grade passed in as a parameter.

      E.g., if the letter

      grade is "A", it returns 4, etc.

      */

      public int letterGradeConverter(String letterGrade) {

            if(letterGrade.equalsIgnoreCase("A")){

                  return 4;

            }else if(letterGrade.equalsIgnoreCase("B")){

                  return 3;

            } else if(letterGrade.equalsIgnoreCase("C")){

                  return 2;

            } else if(letterGrade.equalsIgnoreCase("D")){

                  return 1;

            } else {

                  return 0;

            }

      }    

     

           

     

      public String getId() {

            return id;

      }

      public void setId(String id) {

            this.id = id;

      }

      public String getFirstName() {

            return firstName;

      }

      public void setFirstName(String firstName) {

            this.firstName = firstName;

      }

      public String getLastName() {

            return lastName;

      }

      public void setLastName(String lastName) {

            this.lastName = lastName;

      }

      public String getMajor() {

            return major;

      }

      public void setMajor(String major) {

            this.major = major;

      }

      public String getMinor() {

            return minor;

      }

      public void setMinor(String minor) {

            this.minor = minor;

      }

      public ArrayList<Course> getCoursesTaken() {

            return coursesTaken;

      }

      public void setCoursesTaken(ArrayList<Course> coursesTaken) {

            this.coursesTaken = coursesTaken;

      }

      public ArrayList<Course> getCurrentSemesterCourses() {

            return currentSemesterCourses;

      }

      public void setCurrentSemesterCourses(ArrayList<Course> currentSemesterCourses) {

            this.currentSemesterCourses = currentSemesterCourses;

      }

      public double getGpa() {

            return gpa;

      }

      public void setGpa(double gpa) {

            this.gpa = gpa;

      }

      /*This method copies all of the courses in the list of courses that a student is currently taking into

      the list of courses that a student has already taken. It then calculates the students gpa based on

      the expanded list of coureses that a student has already taken. The list of courses that a student is currently

      taken is then cleared*/

      public void merge() {

            for (Course c : currentSemesterCourses) {

                  /**

                  * adding each courses from the list of courses that a student is currently taking

                  * into the list of coureses that a student has already taken

                  */

                  coursesTaken.add(c);

            }

            currentSemesterCourses.clear();/*clearing all the values*/

            gpa=calculateGpa(); /*calling the method to find the gpa*/

      }    

     

      /*An already implemented toString() method */

      public String toString() {

            DecimalFormat formatter = new DecimalFormat("###.##");

            String gpaString = formatter.format(gpa);

            return "id: " + id + " " + "First Name: " + firstName + " " + "Last Name: " + lastName + " " + "Major: " + major + " " + "Minor: " + minor +

            " " +"Gpa: " + gpaString;

      }

     

      public boolean equals(Object obj) {

            if(obj instanceof Student){

                  Student s=(Student) obj;

                  if(this.id.equals(s.id) && this.firstName.equals(s.firstName) && this.lastName.equals(s.lastName) && this.major.equals(s.major) && this.minor.equals(s.minor) && this.gpa==s.gpa){

                        return true;

                  }

            }

      return false;

      }    

}    

//StudentDriver.java

import java.util.ArrayList;

import java.util.Scanner;

import java.io.File;

import java.io.FileNotFoundException;

public class StudentDriver {

     

      public static void main(String[] args) {

            ArrayList<Course> coursesTaken = new ArrayList<Course>();

            ArrayList<Course> currentSemesterCourses = new ArrayList<Course>();

            Scanner fileScanner = null;

            Scanner fileNameScanner = null;

            coursesTaken = readFile(true, coursesTaken, fileNameScanner, fileScanner);

            currentSemesterCourses = readFile(false, currentSemesterCourses, fileNameScanner, fileScanner);

            Student student = new Student("00001234", "Joe", "Student", "Anthropology", "Biology", coursesTaken, currentSemesterCourses);

     

            student.merge();

            for (Course myCourse : student.getCoursesTaken()) {

                  System.out.println(myCourse);

                  System.out.println();

            }    

           

            System.out.println();

            System.out.println(student);

     

      }

     

      public static ArrayList<Course> readFile(boolean taken, ArrayList<Course> courses, Scanner fileNameScanner, Scanner fileScanner) {

            Scanner lineScanner = null;

            try {

                  fileNameScanner = new Scanner(System.in);

                  if (taken) {

                        System.out.println("Please enter the name of the file with the courses taken: ");

                  } else {

                        System.out.println("Please enter the name of the file with the current courses: ");

                  }

                  String fileName = fileNameScanner.next();

                       

                  File file = new File(fileName);

                  fileScanner = new Scanner(file);

                 

                  while (fileScanner.hasNextLine()) {

                        String line = fileScanner.nextLine();

                        lineScanner = new Scanner(line).useDelimiter("#");

                        lineScanner.useDelimiter("#");

                        String courseDesignator = null;

                        String courseNumber = null;

                        String courseDescription = null;

                        String credits = null;

                        String section = null;

                        String letterGrade = null;

                       

                        if (lineScanner.hasNext()) {

                              courseDesignator = lineScanner.next().trim();

                        }

                        if (lineScanner.hasNext()) {

                              courseNumber = lineScanner.next().trim();

                        }    

                        if (lineScanner.hasNext()) {

                              courseDescription = lineScanner.next().trim();

                        }

                        if (lineScanner.hasNext()) {

                              credits = lineScanner.next().trim();

                        }

                        if (lineScanner.hasNext()) {

                              section = lineScanner.next().trim();

                        }

                        if (lineScanner.hasNext()) {

                              letterGrade = lineScanner.next().trim();

                        }

                        int numCredits = Integer.parseInt(credits);

                        Course course = new Course(courseDesignator, courseNumber, courseDescription, numCredits, section, letterGrade);

                        courses.add(course);

                  }

                  //fileNameScanner.close();

                  fileScanner.close();

            }    

            catch (FileNotFoundException fnfe) {

                  System.out.println("File not found. Exiting.");

                  System.exit(1);

            }

            lineScanner.close();         

            return courses;

      }    

}    

/*Output*/

Please enter the name of the file with the courses taken:

coursesTaken.txt

Please enter the name of the file with the current courses:

CurrentCourses.txt

Course Designator: IT

Course Number: 210

Course Description: Introduction to Programming

Section: 2

Letter Grade: B

Course Designator: IT

Course Number: 214

Course Description: Introduction to Software Development

Section: 1

Letter Grade: A

Course Designator: IT

Course Number: 310

Course Description: Data Structures

Section: 1

Letter Grade: B

Course Designator: IT

Course Number: 414

Course Description: Advanced Object-Oriented Programming with Design Patterns

Section: 2

Letter Grade: C

Course Designator: IT

Course Number: 483

Course Description: Web Applications and User Interface Design

Section: 1

Letter Grade: A

Course Designator: IT

Course Number: 340

Course Description: Introduction to Database Systems

Section: 1

Letter Grade: B

id: 00001234

First Name: Joe

Last Name: Student

Major: Anthropology

Minor: Biology

Gpa: 3.17