Lesson 5, Introduction to Control Structures Part 6, Thermostat Problem

You have been asked to write a program to control the heating and air conditioning of a manufacturing plant.  Depending upon the interior temperature of the plant our program must manipulate the climate control systems.  There are only three settings.  Heating, Cooling and Fan only.  These are mutually exclusive so that when one is turned on the others are turned off.  When the temperature falls below 68 degrees the heating system is turned on, when temperature is between 68 and 78 the fan is only turned on.  When greater than 78 degrees the Cooling System is engaged.  The company has found that the cheapest way to change from one temperature control system to another is to hire Social Science and Humanities graduates from the local four year degree colleges to manually flip the switches.  They will be paid $5.25 an hour without benefits.  They do not foresee any problems getting qualified workers. You will evaluate the provided temperature and tell the worker what setting to engage the climate control system (ie "start the cooling system")

Test Data:  Temperature is 81 so the Cooling System is turned on.

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

 

 

 

 

 

 

 

 

You have been asked to write a program to control the heating and air conditioning of a manufacturing plant.  Depending upon the interior temperature of the plant our program must manipulate the climate control systems.  There are only three settings.  Heating, Cooling and Fan only.  These are mutually exclusive so that when one is turned on the others are turned off.  When the temperature falls below 68 degrees the heating system is turned on, when temperature is between 68 and 78 the fan is only turned on.  When greater than 78 degrees the Cooling System is engaged.  The company has found that the cheapest way to change from one temperature control system to another is to hire Social Science and Humanities graduates from the local four year degree colleges to manually flip the switches.  They will be paid $5.25 an hour without benefits.  They do not foresee any problems getting qualified workers. You will evaluate the provided temperature and tell the worker what setting to engage the climate control system (ie "start the cooling system")

Problem Statement
Assumptions:
1. Only one temperature will be analyzed at a time.
2. Only three climate control systems. 
3.  Getting a degree in a non-marketable major is foolish. 

Input:
1.  The temperature.

Calculations
None

Output:
1. If the temperature is below 68 "Start Heating System)
2. If the temperature is above 78 "Start the Cooling System)
3.  If neither the "Start Fan Only System")
Now write the human Algorithm  Answer

 

 

 

 

 

Human Algorithm:
1.  Input the temperature
 2. If the temperature is below 68 output: ("Start Heating System)
2. If the temperature is above 78 output ("Start the Cooling System)
3.  If neither then output  ("Start Fan Only System")


Now Create the flowchart   Answer

 

 

 

 

 

 

 

 

Flow Chart:


Now Create the VB Script   Answer

 

 

 

VB Script Code:

Data Dictionary:

Temperature (num)

<Script Language= "vbscript">
Dim temperature

temperature = inputbox("What is the temperature?")

If temperature < 68 then
    document.write "Turn on the heat!"

ElseIf temperature > 78 then                            '<--- Notice "ElseIf " is one word
    document.write "Turn on the cooling system!"

Else
    document.write "Turn on the fan!"

end If                                                            '<--- Notice "End If" is two words
</script>