Write a program that uses two classes to produce the required output. The first class should be named ClassA and should have the following two instance variables: name and mark. This class should also have a method called grade which should return “pass” if the value of mark is greater than 50 and “fail” otherwise. The second class should be called ClassB and should have the main method. In the main method instantiate an object of the ClassA and pass “Peter” and 80 as the name and mark respectively. You can give this object the name “p”. Finally, call the grade method of ClassA to determine if peter has passed or failed.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter11: Inheritance And Composition
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question

Write a program that uses two classes to produce the required output. The first class should be named ClassA and should have the following two instance variables: name and mark. This class should also have a method called grade which should return “pass” if the value of mark is greater than 50 and “fail” otherwise. The second class should be called ClassB and should have the main method. In the main method instantiate an object of the ClassA and pass “Peter” and 80 as the name and mark respectively. You can give this object the name “p”. Finally, call the grade method of ClassA to determine if peter has passed or failed.

Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
void method
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
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning