Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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... 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

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions