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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education