Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Class question - This is C++ Programming. It is on an exam review sheet, I want to make sure I am doing this right,

C++ Class question - This is C++ Programming. It is on an exam review sheet, I want to make sure I am doing this right, an answer would be helpful.

a. Declare a class, student, with the following attributes:

Private data:

Two int variables age and classes, a double variable called gpa.

And public functions:

A constructor that takes no parameters (it sets the values of the private data variables to zero).

A member function called inc_age that takes an integer parameter n. inc_age increases the students age by n. inc_age does not return a value.

A member function called inc_classes that takes an integer parameter n. inc_classes increases the students classes by n. inc_classes does not return a value.

A member function called inc_gpa that takes an double parameter n. inc_gpa increases the students gpa by n. inc_gpa does not return a value.

A member function called strange that takes a double parameter n. It returns an integer value.

A member function called print that takes no parameters. print does not return a value.

b. Write a member function definition for the student class called inc_classes. inc_classes takes a single integer parameter n. inc_classes increases the number of classes by n. inc_classes does not return a value

c. Write the member function definition for the student class called strange. strange takes a single double parameter n and returns an integer value. If n is less than the gpa, strange returns the students age. If n equals the gpa, strange returns the product of the students age and number of classes. If n is greater the gpa, strange returns the sum of the students age and number of classes. No values in the class should be changed by strange.)

d. Now consider the application program. Declare a variable called james of type student.

e. Show a function call to the inc_classes member function that will increase the number of classes for james by 2.

f. Show a function call to the strange member function that will work on the variable james with a parameter value of 3.25. The return value from strange should be placed in the integer variable answer.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatio Temporal Database Management International Workshop Stdbm 99 Edinburgh Scotland September 10 11 1999 Proceedings Lncs 1678

Authors: Michael H. Bohlen ,Christian S. Jensen ,Michel O. Scholl

1999th Edition

3540664017, 978-3540664017

More Books

Students also viewed these Databases questions

Question

=+ d. a professor deciding how much to prepare for class

Answered: 1 week ago