A distributor of Christmas items ships a lot of Christmas tree ornaments. They o
ID: 3544922 • Letter: A
Question
A distributor of Christmas items ships a lot of Christmas tree ornaments. They only have one size shipping-box. Sixteen ornaments will fill a shipping-box. Produce the pseudocode logic for an algorithm that will compute the number of shipping-boxes required for the number of ornaments to be shipped. The information is given as follows:
- The output will consist of a screen display showing the number of shipping-boxes needed for a customer's order.
- The input will consist of the number of ornaments ordered by a customer, entered from the keyboard.
- The processing will compute the number of boxes needed to fulfill the order. The number of boxes is computed as: number of ornaments ordered divided by the number of ornaments that will fill a box. If there is a remainder, the number of boxes must be incremented by one.
Note: Your solution should contain a mainline, and at least three subroutines
Explanation / Answer
Here is your pesudocode with 3 subroutines and main
Start
Main :
delare numberOfInputs as integer type
Call input() method and store its value to numberOfInputs
call process (numberOfInputs ) method in which pass the number of inputs as paremeter
store the returned value in to integer type variable, say numberOfBoxes
call the output(numberOfBoxes) method
End Main
input :
Print "Enter the number of ornaments ordered by a customer. "
store the input by the user into integer type variable say noOfInputs
return noOfInputs
End input
process(int noOfOrnaments) :
delcare a integer type variable, say boxCapacity and initialize it to 16
declare a integer type variable, say noOfBoxRequired
declare a integer type variable, say remaining
noOfBoxRequired = noOfOrnaments / boxCapacity
remaining = noOfOrnaments % boxCapacity
IF remaining != 0
noOfBoxRequired = noOfBoxRequired +1
return noOfBoxRequired
End process
output(int numberOfBoxes) :
print "he number of shipping-boxes needed for the customer's order is " numberOfBoxes
End output
End
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.