Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

a Method setAvgLbSoldpoundsSoldLast12Months Const MONTHS... 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

Java An Introduction To Problem Solving And Programming

Authors: Walter Savitch

8th Edition

0134462033, 978-0134462035

More Books

Students also viewed these Programming questions