Lesson 5, Introduction to Control Structures
Part 5, Nursery Problem

You have been tasked to write a computer program for a nursery to find out how much fertilizer is needed to be administered to the different plants they have each day.   The fertilizer is administered based upon the size of the pot the plants are in (measured by the number of gallons the pot can hold).  There are three different size pots. There are 5 gallon pots, 10 gallon pots and 25 gallon posts.  Each plant is given 5 ounces of liquid fertilizer per gallon of  pot if the expected mean temperature is greater then 80 degrees, 3 ounces if below 50 degrees, and 4 ounces if it 50 through 80 degrees.  Your program is to tell the user how many gallons of fertilizer will be used each day so they know how much to make in the morning.  (Math:  There are 128 ounces in a gallon)

First Let's do the problem statement for this:
Assumptions
Input
Calculations
Output
Answer

Test data:  10 of each type of pot (5, 10, and 25 gallon) and 70 degrees they will require 12.5 Gallons of fertilizer.

 

 

 

 

 

 

 

You have been tasked to write a computer program for a nursery to find out how much fertilizer is needed to be administered to the different plants they have each day.   The fertilizer is administered based upon the size of the pot the plants are in (measured by the number of gallons the pot can hold).  There are three different size pots. There are 5 gallon pots, 10 gallon pots and 25 gallon posts.  Each plant is given 5 ounces of liquid fertilizer per gallon of  pot if the expected mean temperature is greater then 80 degrees, 3 ounces if below 50 degrees, and 4 ounces if it 50 through 80 degrees.  Your program is to tell the user how many gallons of fertilizer will be used each day so they know how much to make in the morning.  (Math:  There are 128 ounces in a gallon)

Problem Statement
Assumptions:
1. Only 3 types of pots
2. Single type of fertilizer is administered consistently based upon temperature 
3. There are 128 ounces in a gallon 
4.  Calculation is only done at the beginning of each day.

Input:
1.  Number of 5 gallon pots
2.  Number of 10 gallon pots
3.  Number of 25 gallon pots
4.  Expected mean temperature


Calculations
1.  Total gallons of 5 gallon plants is number of 5 gallon pots * 5
2.  Total gallons of 10 gallon plants is number of 10 gallon pots * 10
3.  Total gallons of 25 gallon plants is number of 25 gallon pots * 25
4.  Total gallons of pots is total gallons of 5 + total gallons of 10 + total gallons of 25
5.  If it is the mean temp > 80 then
6.         total ounces of fertilizer = total Gallons * 5  (go to 7)
7.  If the mean temp < 50 then
8.         total ounces of fertilizer = total Gallons * 3
     Any other temperature then
9           total ounes of fertiizer = total gallons * 4
10.  Total Gallons of fertilizer = total ounces / 128

Output:
1. The number of gallons of fertilizer
Now write the human Algorithm  Answer

 

 

 

 

 

Human Algorithm:
1.  Input the # of 5 gallon pots
2. Input the # of 20 gallon pots
3. Input the # of 25 gallon pots
4. Input the mean temperature.
5. Total gallons of 5 gallon plants is number of 5 gallon pots * 5
6.  Total gallons of 10 gallon plants is number of 10 gallon pots * 10
7.  Total gallons of 25 gallon plants is number of 25 gallon pots * 25
8.  Total gallons of pots is total gallons of 5 + total gallons of 10 + total gallons of 25
9.   If it is the mean temp > 80 then
10.         total ounces of fertilizer = total Gallons * 5
11.  If the mean temp < 50 then
12.         total ounces of fertilizer = total Gallons * 3
13.  Any other temperature then
14           total ounces of fertilizer = total gallons * 4
15.  Total Gallons of fertilizer = total ounces / 128

16. Output the total gallons


Now Create the flowchart   Answer

 

 

 

 

 

 

 

 

Flow Chart:


Now Create the VB Script   Answer

 

 

 

 

 

 

 

 

VB Script Code:

<script language =vbscript>
Option Explicit
Dim num5gal, num10gal, num25gal, temp, ttl5gal, ttl10gal, ttl25gal
Dim ttlgallons, ttlouncefert, ttlGallonfert

num5gal = inputbox("number of 5 gallon pots?")
num10gal = inputbox("number of 10 gallon pots?")
num25gal = inputbox("number of 25 gallon pots?")
temp = inputbox("What is the estimated mean temperature?")

ttl5gal = num5gal * 5
ttl10gal = num10gal * 10
ttl25gal = num25gal * 25

ttlgallons = ttl5gal + ttl10gal + ttl25gal

If temp > 80 then
    ttlouncefert = ttlgallons * 5
Elseif temp <50 then
    ttlouncefert = ttlgallons * 3
Else
    ttlouncefert = ttlgallons * 4
End If

ttlGallonfert = ttlouncefert/128
document.write "The total number of gallons of fertilizer you will need is " & ttlGallonfert

</script>