Question: Consider the following class definition: Class Candy Private String name Private Real lbPrice Private Real avgLbSold

Consider the following class definition:  

Class Candy  

   Private String name  

   Private Real lbPrice  

   Private Real avgLbSold  

   Public Module Candy ()  

       Set name = " "  

       Set lbPrice = 0  

       Set avgLbSold = 0  

   Return  

  

   Public Module Candy (String newName, Real newLbPrice,  

                        Real newAvgLbSold)  

       Set name = newName  

       Set lbPrice = newLbPrice  

       Set avgLbSold = newAvgLbSold  

   End Module  

  

   Public Function String getName()  

       Return name  

   End Function  

  

   Public Module setName (String newName)  

       Set name = newName  

   End Module  

  

   Public Function Real getLbPrice ()  

       Return lbPrice  

   End Function  

  

   Public Function Real getAvgLbSold()  

       Return avgLbSold  

   End Function  End Class  

Write the pseudocode for the following methods that will be added to the Candy class. 

a.    Write pseudocode for a setAvgLbSold() method that inputs the number of pounds sold each month for the last 12 months and then calculates avgLbSold. (Be sure to define and use a constant for the number of months.)  

  

b.    Write pseudocode for a setAvgLbSold() method that inputs the number of pounds sold each day of last month then calculates avgLbSold. The user starts by entering the number of days in last month.  

Step by Step Solution

3.39 Rating (155 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

a Method setAvgLbSoldpoundsSoldLast12Months Const MONTHS... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!