Question
Unloading vehicle of groceries The bagsCarried can be a value of 1 through 4 bags at a time. The bagsInVehicle is the total number of
Unloading vehicle of groceries
The bagsCarried can be a value of 1 through 4 bags at a time. The bagsInVehicle is the total number of bags currently in my truck. The value of bags carried will be subtracted from the total number of bags within the vehicle until the number of bags within the vehicle equals 0. I normally try to take as many bags as possible on the first trip, but I know that taking only 2 bags per hand is a great way of not ruining any groceries or dropping any bags.
The pseudo code for unloading grocery bags from a vehicle is as follows below:
while (I still have grocery bags in my truck)
if (bags taken from vehicle is 1)
add 1 to bagsCarried
Subtract 1 from bagsInVehicle
if (bags taken from vehicle is 2)
add 2 to bagsCarried
Subtract 2 from bagsInVehicle
if (bags taken from vehicle is 3)
add 3 to bagsCarried
Subtract 3 from bagsInVehicle
if (bags taken from vehicle is 4)
add 4 to bagsCarried
Subtract 4 from bagsInVehicle
if (bagsInVehicle > 0)
I still have more grocery bags within my truck
else
I have taken all of the grocery bags from my truck.
Explain whether their pseudo code methods appropriately address all objects within the collection. If not, suggest code that should be added or modified. If you determine their code is complete as written, explain why.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
The pseudo code provided seems to appropriately address the task of unloading grocery bags from a ve...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started