Problem : Dr Becky need your help to determine which students are eligible for C
ID: 3661753 • Letter: P
Question
Problem : Dr Becky need your help to determine which students are eligible for CSC1311-Computer Programming 2. She wants you to write a Java program to accomplish this feat. STUDENT WHO PASS csc1310-COMPUTER PROGRAMING 1 WITH grade of C or better (A,B) can enroll in CSC 1311-computer Programming2.your program should verify the following students are eligible.
Banner ID ---------------------Grade
54000001----------------------- D
54000011 ---------------------A
54000201---------------------- F
54600023==------------------ I
54020002 ----------------------C
54002004-------------------- B
54602222 --------------------W
you must write your program in methods including accessors and mutator.
use a loop to process the students.
Sumit algorithm(typed),
Programs(source code Java),
Sample output Comment
Explanation / Answer
/**
* The Student class has methods to set the banner id and
* grade.
* */
//Student.java
public class Student
{
//instance variables
private int bannerID;
private char grade;
//constructor
public Student()
{
bannerID=0;
grade=' ';
}
//Parameter constructor that takes bannerID and grade as input
//arguments to set instance variables
public Student(int bannerID, char grade)
{
this.bannerID=bannerID;
this.grade=grade;
}
//Mutator methods
public void setBanner(int bannerID)
{
this.bannerID=bannerID;
}
public void setGrade(char grade)
{
this.grade=grade;
}
//Accessor methods
public int getBanner()
{
return bannerID;
}
public char getGrade()
{
return grade;
}
//Returns the string representation of the Student object
@Override
public String toString() {
return "Banner id : "+bannerID+" Grade : "+grade;
}
}
---------------------------------------------------------------------------------------------------------
/**
* The java program that prints the eligible students list
* for course cse1311 whose grade is 'c' and above 'a' and 'b'.
* */
//CSC1311.java
public class CSC1311
{
public static void main(String[] args)
{
final int size=7;
//Create an Student array of size
Student[] CSE1310_STUDENTS=new Student[size];
//Create a list of the Student
CSE1310_STUDENTS[0]=new Student(54000001, 'D');
CSE1310_STUDENTS[1]=new Student(54000011, 'A');
CSE1310_STUDENTS[2]=new Student(54000201, 'F');
CSE1310_STUDENTS[3]=new Student(54600023, 'I');
CSE1310_STUDENTS[4]=new Student(54002002, 'C');
CSE1310_STUDENTS[5]=new Student(54002004, 'B');
CSE1310_STUDENTS[6]=new Student(54602222, 'W');
System.out.println("CSE1311-ELIGIBLE STUDENTS LIST");
for (int index = 0; index < CSE1310_STUDENTS.length;
index++) {
//Call the method isEligibleForCSE1311 with Student object
if(isEligibleForCSE1311(CSE1310_STUDENTS[index]))
System.out.println(CSE1310_STUDENTS[index]);
}
}
/**The method isEligibleForCSE1311 that takes Student as argument
* that returns true if the student's grade is either C, A or B
* otherwise returns false*/
private static boolean isEligibleForCSE1311(Student student)
{
//set selected false
boolean selected=false;
//set selected to true if grade is C or A or B
if(student.getGrade()=='C' || student.getGrade()=='A' ||student.getGrade()=='B')
selected=true;
//return
return selected;
}
}
---------------------------------------------------------------------------------------------------
Sample Output:
Banner id : 54000011 Grade : A
Banner id : 54002002 Grade : C
Banner id : 54002004 Grade : B
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.