Question: Part I: Create an application to record student courses and grades. The application should also p……

Part I: Create an application to record student courses and grades. The application should also print a student’s transcript. There are four programmer-defined classes in the application: Course – record student name, course title, credit and final grade. Transcript – create a collection of Course to perform record adding, deleting, sorting, searching, and printing operations. You may use any class in the Collections. Validator – verify data entries of the credit (no letter or negative number) and final grade (must be a valid letter grade) TranscriptApp – driver class to test your operation classes. your program will ask use to create a course record with the name, title of course, credit and final grade until user entered “n” to stop, and then it will display the options for adding, deleting, sorting, searching, and printing of student records. Data entries for credit and final grade must be validated using Validator class and you may use or modify any version of Validator class you have created in your previous labs or provided in the book examples.

Expert Answer

answers

Note: Do refer to the comments to better understand the working of the code.

Don't use plagiarized sources. Get Your Custom Essay on
Question: Part I: Create an application to record student courses and grades. The application should also p……
Get an essay WRITTEN FOR YOU, Plagiarism free, and by an EXPERT!
Order Essay

===============

     Course.java

===============

package coursehubs;

public class Course {
// private data fields
private String studentName;
private String courseTitle;
private int credit;
private String finalGrade;

// Constructor to store values
public Course(String studentName, String courseTitle, int credit, String finalGrade) {
super();
this.studentName = studentName;
this.courseTitle = courseTitle;
this.credit = credit;
this.finalGrade = finalGrade;
}

// Getter and Setter methods
public String getStudentName() {
return studentName;
}
public void setStudentName(String studentName) {
this.studentName = studentName;
}
public String getCourseTitle() {
return courseTitle;
}
public void setCourseTitle(String courseTitle) {
this.courseTitle = courseTitle;
}
public int getCredit() {
return credit;
}
public void setCredit(int credit) {
this.credit = credit;
}
public String getFinalGrade() {
return finalGrade;
}
public void setFinalGrade(String finalGrade) {
this.finalGrade = finalGrade;
}
// Check if two courses are equal
public boolean equals(Course other) {
return this.courseTitle.equals(other.courseTitle) && this.studentName.equals(other.studentName);
}

// String representation
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(“Student: ” + this.studentName + “n”);
sb.append(“Course: ” + this.courseTitle + “n”);
sb.append(“Credits: ” + this.credit + “n”);
sb.append(“Grade: ” + this.finalGrade + “n”);
return sb.toString();
}

}

===============

Transcript.java

===============

package chegg;

import java.util.ArrayList;
import java.util.Comparator;

class NameComparator implements Comparator<Course>{
// Custom comparator to sort by names
@Override
public int compare(Course o1, Course o2) {
return o1.getStudentName().compareTo(o2.getStudentName());
}

}

public class Transcript {
Validator validator;
ArrayList<Course> courses;
public Transcript(Validator validator) {
super();
this.validator = validator;
this.courses = new ArrayList<>();
}

public boolean addCourse(Course c) {
// Validate course before adding
if(this.validator.Validate(c)) {
this.courses.add(c);
return true;
}else {
return false;
}
}

public void delete(Course c) {
// Delete the course from transcript
int index = -1;
for(int i=0; i<this.courses.size(); ++i) {
if(c.equals(this.courses.get(i))) {
index = i;
break;
}
}
if(index > -1) {
this.courses.remove(index);
}
}
public boolean search(Course c) {
// Search for a specific course
for(int i=0; i<this.courses.size(); ++i) {
if(this.courses.get(i).equals(c)) {
return true;
}
}
return false;
}
public void print() {
// Print the transcript
System.out.println(“Transcript”);
for(int i=0; i<this.courses.size(); ++i) {
System.out.println(this.courses.get(i));
}
}
public void sort() {
// Sort using custom comparator
this.courses.sort(new NameComparator());
}
}

===============

    Validator.java

===============

package chegg;

import java.util.Set;

public class Validator {
private Set<Integer> validCredits;
private Set<String> validGrades;
public Validator(Set<Integer> validCredits, Set<String> validGrades) {
super();
this.validCredits = validCredits;
this.validGrades = validGrades;
}
public Set<Integer> getValidCredits() {
return validCredits;
}
public void setValidCredits(Set<Integer> validCredits) {
this.validCredits = validCredits;
}
public Set<String> getValidGrades() {
return validGrades;
}
public void setValidGrades(Set<String> validGrades) {
this.validGrades = validGrades;
}

public boolean Validate(Course c) {
// Validate grades and credits
if(this.validCredits.contains(c.getCredit()) && this.validGrades.contains(c.getFinalGrade())) {
return true;
}else {
return false;
}
}
}

===============

TranscriptApp.java

===============

package chegg;

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class TranscriptApp {

public static void main(String[] args) {

// Custom grades as per requirement
Set<String> validGrades = new HashSet<>();
validGrades.add(“AA”);
validGrades.add(“AB”);
validGrades.add(“BB”);
validGrades.add(“BC”);
validGrades.add(“CC”);
validGrades.add(“CD”);
validGrades.add(“DD”);
validGrades.add(“F”);

// Custom credits as per requirement
Set<Integer> validCredits = new HashSet<>();
validCredits.add(1);
validCredits.add(2);
validCredits.add(3);
validCredits.add(4);

// Creating some sample courses
Course c1 = new Course(“Chegg Student 1”, “Computer Systems”, 4, “AA”);
Course c2 = new Course(“Chegg Student 2”, “Information Systems”, 3, “BC”);
Course c3 = new Course(“Chegg Student 3”, “Systems Security”, 5, “E”);// Should be F, should not be 5

// Prepare validator
Validator validator = new Validator(validCredits, validGrades);
System.out.println(“C1 validated: ” + validator.Validate(c1));
System.out.println(“C2 validated: ” + validator.Validate(c2));
System.out.println(“C3 validated: ” + validator.Validate(c3));
c3 = new Course(“Chegg Student 3”, “Systems Security”, 3, “F”);
System.out.println(“C3 validated: ” + validator.Validate(c3));

Transcript transcript = new Transcript(validator);
transcript.addCourse(c3);
transcript.addCourse(c2);
transcript.addCourse(c1);
System.out.println(“Before sorting!”);
transcript.print();
System.out.println(“After sorting!”);
transcript.sort();
transcript.print();
transcript.delete(c3);
transcript.print();
System.out.println(“Transcript contains c3: ” + transcript.search(c3));

// Ask for user input
transcript = new Transcript(validator);
Scanner in = new Scanner(System.in);
System.out.print(“Add more records (y/n): “);
String more = in.nextLine();
while(!more.equals(“n”)) {
System.out.print(“Enter Name: “);
String name = in.nextLine();
System.out.print(“Enter title: “);
String title = in.nextLine();
System.out.print(“Enter Credits: “);
int credits = Integer.parseInt(in.nextLine());
System.out.print(“Enter Grade: “);
String grade = in.nextLine();
Course temp = new Course(name, title, credits, grade);
transcript.addCourse(temp);
System.out.print(“Add more records (y/n): “);
more = in.nextLine();
}
transcript.print();
}

}

Do Upvote if this helps!

Top Grade Homework
Order NOW For a 10% Discount!
Pages (550 words)
Approximate price: -

Why Work with Us

Top Quality and Well-Researched Papers

We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.

Professional and Experienced Academic Writers

We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

24/7 Customer Support

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

Essays

Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.

Admissions

Admission Essays & Business Writing Help

An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.

Reviews

Editing Support

Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.

Reviews

Revision Support

If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.

× Contact Live Agents