In this lab you will complete a program that reads students' name and score and displays students' name, score and letter grade that is calculated based on the above table. Each line of output corresponding to an honor student should be marked by a *. Given classes: • Class LabProgram contains the main method for testing the program. • Class Course represents a course, which contains an ArrayList of Student objects as a course roster. • Class Student represents a regular student, which has three fields: first name, last name, and score. • Class HonorStudent is derived from the class Student and represents an honor student. This class has a constructor and overrides methods getGrade and toString of its super class.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

import java.util.Scanner;
import java.util.ArrayList;

public class LabProgram {
       public static void main(String[] args) {

        Course cop3804=new Course();
        String fn, ln;
        int score;
        String studentType;
        
        Scanner kb=new Scanner(System.in);
        studentType=kb.next();
        
        while (!studentType.equals("q")) {
            fn = kb.next();
            ln = kb.next();
            score=kb.nextInt();
            if (studentType.equals("R"))
                cop3804.addStudent(new Student(fn, ln, score));
            else
                cop3804.addStudent(new HonorStudent(fn, ln, score));
            studentType = kb.next();
        } 
        cop3804.print();
    }

}

import java.util.ArrayList;

public class Course {

    private ArrayList<Student> roster; //collection of Student objects

    public Course() {
        roster = new ArrayList<Student>();
    }

    public void addStudent(Student s) {
        roster.add(s);
    }
    
    public void print(){
       /* displays the class roster and student grades */
       /* Type your code here */
    }
}

import java.text.DecimalFormat;

// Class representing a student
public class Student {
    private String first;
    private String last;
    private int score;

    public Student (String f, String l, int score) {
        first=f;
        last=l;
        this.score=score;
    }
     
    public void setScore(int score) {
        this.score=score;
    }
    
    public int getScore() {
       return (score);
    }

    public char getGrade() {
       /* returns student's grade */
       /* Type your code here */
    }
    
    @Override
    public String toString() {
        return (String.format("%-10s  %-10s  %3d", first, last, score));
    }
}

public class HonorStudent extends Student{

    public HonorStudent (String f, String l, int score) {
      /* HonorStudent constructor */
      /* Type your code here */
    }

    @Override
    public char getGrade() {
      /* returns honor student's letter grade */
      /* Type your code here */
      
    }
    
    
    @Override
    public String toString() {
       /* returns honor student's information followed by a "*" */
       /* Hint. concatendate "*" to the end of the string returned */
       /* by the toString function of the super class */
       /* Type your code here */

    }
}

4.4 LAB: Student grades
Honor students and regular students can both enroll in the same courses, but their final grades are calculated differently based on the
following table:
In this lab you will complete a program that reads students' name and score and displays students' name, score and letter grade that is
calculated based on the above table. Each line of output corresponding to an honor student should be marked by a **.
Given classes:
• Class LabProgram contains the main method for testing the program.
Class Course represents a course, which contains an ArrayList of Student objects as a course roster.
• Class Student represents a regular student, which has three fields: first name, last name, and score.
• Class HonorStudent is derived from the class Student and represents an honor student. This class has a constructor and overrides
methods getGrade and toString of its super class.
Your task is to complete the following methods:
• Class Course:
}
Honor Student Grades
score >=95, A
95 > score >= 90, B
90 > score >= 85, C
85 > score >= 70, D
70 > score, F
public void print () {
/* displays the class roster and student grades */
Class Student:
public char getGrade () {
Regular Student Grades
score >=90, A
90 > score >= 80, B
80> score >= 70, B
70 > score >= 60, B
60 > score, F
}
/* returns student's grade */
Transcribed Image Text:4.4 LAB: Student grades Honor students and regular students can both enroll in the same courses, but their final grades are calculated differently based on the following table: In this lab you will complete a program that reads students' name and score and displays students' name, score and letter grade that is calculated based on the above table. Each line of output corresponding to an honor student should be marked by a **. Given classes: • Class LabProgram contains the main method for testing the program. Class Course represents a course, which contains an ArrayList of Student objects as a course roster. • Class Student represents a regular student, which has three fields: first name, last name, and score. • Class HonorStudent is derived from the class Student and represents an honor student. This class has a constructor and overrides methods getGrade and toString of its super class. Your task is to complete the following methods: • Class Course: } Honor Student Grades score >=95, A 95 > score >= 90, B 90 > score >= 85, C 85 > score >= 70, D 70 > score, F public void print () { /* displays the class roster and student grades */ Class Student: public char getGrade () { Regular Student Grades score >=90, A 90 > score >= 80, B 80> score >= 70, B 70 > score >= 60, B 60 > score, F } /* returns student's grade */
Class HonorStudent:
public HonorStudent (String f, String 1, int score) {
/* HonorStudent constructor */
}
@Override
public char getGrade () {
/* returns honor student's letter grade */
}
@Override
public String toString() {
/* returns honor student's information followed by a "*" */
/* Hint. concatendate "*" to the end of the string returned */
/* by the toString function of the super class */
}
For example, for the input:
R Henry Nguyen 90
R Brenda Stern 85.
H Lynda Robison 95
H Sonya King 65
R Henri Seiko 75
R Robert Smith 65
H Maria Johnson 75
R Michael Dutt 50
q
The output is:
Henry
Brenda
Lynda
Sonya
Henri
Robert
Maria
Michael
Nguyen
Stern
Robison
King
Seiko
Smith
Johnson
Dutt
90 A
85 B
95* A
65* F
75 C
65 D
75* D
50 F
Transcribed Image Text:Class HonorStudent: public HonorStudent (String f, String 1, int score) { /* HonorStudent constructor */ } @Override public char getGrade () { /* returns honor student's letter grade */ } @Override public String toString() { /* returns honor student's information followed by a "*" */ /* Hint. concatendate "*" to the end of the string returned */ /* by the toString function of the super class */ } For example, for the input: R Henry Nguyen 90 R Brenda Stern 85. H Lynda Robison 95 H Sonya King 65 R Henri Seiko 75 R Robert Smith 65 H Maria Johnson 75 R Michael Dutt 50 q The output is: Henry Brenda Lynda Sonya Henri Robert Maria Michael Nguyen Stern Robison King Seiko Smith Johnson Dutt 90 A 85 B 95* A 65* F 75 C 65 D 75* D 50 F
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY