Create a class named Grades, which has four fields, one for the name of the student, and three other fields for grades in test1, test2 and test3. The class should contain two constructors: a no-argument constructor that sets all fields to zero, and a constructor that sets all fields to a given value. The class should have the appropriate methods to “set” and “get” the values of all fields. The class should also have a method to calculate the average of the three tests. To test the class, you should create a class demo that instantiates one object of the Grades class and asks the user enter the student name and the grades for the three tests. The program should set the fields to the values entered by the user using the “set” methods, and output to the console the student name, the grades for test1, test2 and test3 as well as their average using “get” methods.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter4: More Object Concepts
Section: Chapter Questions
Problem 4PE
icon
Related questions
Question

Create a class named Grades, which has four fields, one for the name of the student, and three other fields for grades in test1, test2 and test3. The class should contain two constructors: a no-argument constructor that sets all fields to zero, and a constructor that sets all fields to a given value. The class should have the appropriate methods to “set” and “get” the values of all fields. The class should also have a method to calculate the average of the three tests. To test the class, you should create a class demo that instantiates one object of the Grades class and asks the user enter the student name and the grades for the three tests. The program should set the fields to the values entered by the user using the “set” methods, and output to the console the student name, the grades for test1, test2 and test3 as well as their average using “get” methods.    

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Class
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
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning