A GradeBook Example : In this example ,GradeBook class has one attribute and some methods to access this attribute data: public class GradeBook { private String cname; public void setName(String name){ cname=name; } public String getName(){ return cname; } public void showMessage(){ System.out.printf("Welcome to the Grade Book of %s \n", getName()); } } //End of Class Test Class Example that uses GradeBook class: public class GradeBookTest { public static void main(String[] args) { GradeBook b1=new GradeBook(); GradeBook b2=new GradeBook(); System.out.printf("Course Name %s \n",b1.getName()); System.out.printf("Course Name %s \n",b2.getName()); b1.setName("Object Oriented Programming"); b2.setName("Data Structure using Java"); System.out.printf("Course Name %s \n",b1.getName()); System.out.printf("Course Name %s \n",b2.getName()); b1.showMessage(); b2.showMessage(); } }//End class   Exercise: You need to include another two attribute with name “marks” and “totalstudents” in GradeBook Class, Use functions to set and get its value and write another function “CalculateGrade()” [function can return Boolean value true or false, for example if marks are >50 it should return true, otherwise return false. Use this function in main method to test Pass and fail condition. Use them in GradeBookTest Class

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter1: Creating Java Programs
Section: Chapter Questions
Problem 9RQ
icon
Related questions
Question

A GradeBook Example : In this example ,GradeBook class has one attribute
and some methods to access this attribute data:
public class GradeBook {

private String cname;

public void setName(String name){

cname=name;
}
public String getName(){
return cname;
}

public void showMessage(){
System.out.printf("Welcome to the Grade Book of %s \n", getName());
}
} //End of Class
Test Class Example that uses GradeBook class:
public class GradeBookTest {
public static void main(String[] args) {

GradeBook b1=new GradeBook();
GradeBook b2=new GradeBook();


System.out.printf("Course Name %s \n",b1.getName());
System.out.printf("Course Name %s \n",b2.getName());

b1.setName("Object Oriented Programming");
b2.setName("Data Structure using Java");

System.out.printf("Course Name %s \n",b1.getName());
System.out.printf("Course Name %s \n",b2.getName());

b1.showMessage();
b2.showMessage();
}
}//End class

 

Exercise:
You need to include another two attribute with name
“marks” and “totalstudents” in GradeBook Class, Use
functions to set and get its value and write another
function “CalculateGrade()” [function can return Boolean
value true or false, for example if marks are >50 it
should return true, otherwise return false. Use this
function in main method to test Pass and fail condition.
Use them in GradeBookTest Class.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT