Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Programming - need help with modules?

Okay so I have to design a program that uses modules that requires me to find the total cost of something... Without getting into specifics, the user is prompted to enter 2 inputs, and I am able to find the cost of labor, as well as the cost of paint in two seperate modules... How can I create a module that adds the result of the costOfLabor module and the costOfPaint module?

Total cost = cost of labor + cost of paint

Sorry, I forgot to add I am just creating a pseudocode program

1 Answer

Relevance
  • 7 years ago

    To modularize that process, I would expect you to create one module for gathering inputs and another for computing costs rather than separate modules for computing each cost.

    Modularization is normally done following a function decomposition and it normally produces modules for the functions to be performed... something like increasing a basic cost by a tax amount is the same function, regardless of what' the cost is paying for.

    Interacting with a user, on the other hand, is a totally different operation than calculating a cost. If I assign a task like this, dividing the process along functional lines like this is what I'd be looking for. (I'll leave it to you to decide your steps to pseudocode in a module for getting user input or one for totalling cost components -- that should be pretty straightforward.)

Still have questions? Get your answers by asking now.