Introduction to Fortran

Simple Program Construction with Pseudocode » Laundry!

We haven’t figured out when we should do laundry or even if we have enough clothes to wear for today. How are we going to make that happen?

Let’s assume that we don’t need to track individual pieces of clothing. We just need to track how many of each type of clothing we have. We could also then track how many of each type of clothing is still clean. It is really nice to think of your wardrobe as a table of data.

Tops

Bottoms

Short-sleeved

Long-sleeved dress

T-shirt

Long-sleeved

Shorts

Pants

Athletic shorts

Pajama pants

6

3

3

2

5

5

3

2

The first row of the table is unnecessary, but is here to make it clearer what each column is referring to. One could also make two separate tables, one for tops and one for bottoms. It is more efficient to use only one table, but it may be harder to think about that framework if this is your first time programming.

When we pick out an outfit, we would then need to subtract those pieces of clothing from our wardrobe. Let’s assume that if we get down to zero clean individual pieces of clothing, we would want to do laundry. So we would then also want to send a message to ourselves to do the laundry to make sure we do some before the next day.

Question 1 of 2

Using the pseudocode we have written so far, where would you put the subtraction from the wardrobe for the most efficient coding/least repetition of the same pseudocode? Type into the code in the box to add your subtraction text.


Although you may have been tempted to place the subtraction immediately after the selection of that piece of the outfit, it is making you repeat the pseudocode. Instead, it is best to place the subtraction at the end of the program so you would only have to do the subtraction once and you wouldn’t have to repeat the pseudocode four separate times.