Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The pseudocode listed below creates a class called Membership. The purpose of th

ID: 3856824 • Letter: T

Question


The pseudocode listed below creates a class called Membership. The purpose of the class is to determine the the cost of membership to a local health clug. The user will create an object based on the class and send in to it the type of membership the user wants either single or family. The class will also calculates if the user wants any additional costs such as tennis, rock climbing or time with a personal trainer

Which line of code prints dues?

class Membership

     begin constructor (usertype as string)

           private type as string

          private extras as string

          private extracost as float

         private dues as float

          DetermineBaseCost

          DetermineExtras

     end constructor

begin DetermineBaseCost

     if type = "Single" then

          dues = 50

     else

           dues = 100

     end if

end

begin DetermineExtras

     print "Enter T for tennis, R for rock climbing P for personal trainer or N for none. Enter Q to quit"

     input extras

     while extras != "Q"

          if extras = "T" then

               dues = dues + 25

          else if extras = "R" then

               dues = dues + 100

          else if extras = "P"

               dues = dues + 50

          else

               dues = dues + 0

          end if

          print "Enter T for tennis, R for rock climbing or P for personal trainer. Enter Q to quit"

          input extras

     end loop

end

begin ReturnDues

     return dues

end

end class

A. ) print "Your annual dues are: " + dues

B. )print "Your annual dues are: " + my_dues

Explanation / Answer

The data member which stores dues is:

private dues as float

Now, since "dues" variable is private. It cannot be accessed directly from outside functions(i.e Functions which are not a member of that class). Fortunately, the code provides a public function "ReturnDues", which returns the value of variable "dues".(As public members can be directly accessed by external entities).

So, in order to get the dues, we need to call "Return Dues" function from the object of class "Membership".

Hence, the answer shall be C.) my_membership.ReturnDues, where I assume my_membership to an object of class membership.

Note: Option A.) could also been an answer, if it was written inside a member function of class "Membership". Because then the private variable "dues" could had been accessed directly.