Question: Help me come up with a for each statement to print their letter grade. this is the code i have so far and then this
Help me come up with a for each statement to print their letter grade. this is the code i have so far and then this is the given code from student.java
public class GradeBook
public static void mainString args
final String GRADEDELIMITERS ;
TODO: Create a new ArrayList of Student objects called gradebook.
ArrayList gradebook new ArrayList;
START PHASE TODO ITEMS
TODO: Create student objects to populate your ArrayList using the following
Student
First Name: Samwise
Last Name: Gamgee
Student ID:
Grade:
Student
First Name: Frodo
Last Name: Baggins
Student ID:
Grade:
Student
First Name: Pippin
Last Name: Took
Student ID:
Grade:
Student
First Name: Meriadoc
Last Name: Brandybuck
Student ID:
Grade:
Student s new StudentSamwise "Gamgee", ;
Student s new StudentFrodo "Baggins", ;
Student s new StudentPippin "Took", ;
Student s new StudentMeriadoc "Brandybuck", ;
gradebook.adds;
gradebook.adds;
gradebook.adds;
gradebook.adds;
END PHASE TODO ITEMS
Student.java
public class Student
private String firstName;
private String lastName;
private int id;
private int grade;
Create a new student object
@param firstName First name of student
@param lastName Last name of student
@param id Student's id number
public StudentString firstName, String lastName, int id
this.firstName firstName;
this.lastName lastName;
this.id id;
this.grade ;
@return the firstName
public String getFirstName
return firstName;
@param firstName the firstName to set
public void setFirstNameString firstName
this.firstName firstName;
@return the lastName
public String getLastName
return lastName;
@param lastName the lastName to set
public void setLastNameString lastName
this.lastName lastName;
@return the id
public int getId
return id;
@param id the id to set
public void setIdint id
this.id id;
@return the grade
public int getGrade
return grade;
@param grade the grade to set
public void setGradeint grade
this.grade grade;
Get a letter grade that represents the student's current score
@return String containing the letter grade representing the student's course grade
public String getLetterGrade
String letterGrade;
if thisgrade
letterGrade A;
else if thisgrade
letterGrade B;
else if thisgrade
letterGrade C;
else if thisgrade
letterGrade D;
else if thisgrade
letterGrade F;
else
letterGrade No grades have been entered for student";
return letterGrade;
@Override
public String toString
String output ;
String letter this.getLetterGrade;
output this.firstName this.lastName has letterequalsAletterequalsFan :a letter ;
return output;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
