![]() |
Lesson Plan |
| IMOS Home | Student Center | TallTech Home |
March 2, 2000Details
Reading / References
|
Accept keyboard input
About decision structure
How to use an if statement
How to use an if/else statement
Using compound statements
How to nest if statements
AND / OR
Operator Precedence
Assignment #: JA01
Assignment: Input/Selection
Due: Mar 7/2000
Marks: 10 marks (5 marks each)
Exercise 2 from chapter 4, section A (pg 156-157)
Exercise 4 from chapter 4, section B (pg 173)
Simple keyboard input (pg 135)
Flowcharts (pg 141)
Decisions with flowcharts (pg 142)
IF structure (pg 143)
Comparison operators (pg 144)
IF/ELSE (pg 146)
Compound statements (pg 148)
Nesting (pg 152)
AND/OR (pg 159-160)
Operator precedence (pg 168-169)
Switch statement (pg 164-165)
Samples:
UPDATED WEIGHT CONVERTER
RECORD RAINFALL
MONTH SELECTOR
1.
UPDATED WEIGHT CONVERTER
Create a weight converter as from last class. This
converter should be able to handle conversions either direction. A variable
should be passed as the parameter that will allow the decision of which way to
convert. Use a string variable as the parameter: Direction = "K"
indicates conversion from Kilos to Lbs, Direction = "L" indicates
conversion from Lbs to Kilos.
2.
RECORD RAINFALL
The average high and average low rainfall for July are 24mm
and 11mm respectively. Write a program that allows the user to enter the
rainfall for July. The program then determines if the rainfall was within the
average rainfall range.
Define three variables:
Var RainFall
Var MaxRain = 24
Var MinRain = 11
Assign a value to RainFall to a number of your choice.
Test the value of rainfall against the minimum and maximum
rainfall. There is actually two tests to make: is RainFall greater than or equal
to min? And is Rainfall less than or equal to Max? Here is how we would form
this complex logical expression:
RainFall>=MinRain && RainFall<=MaxRain
Write the conditional statements that will display either
"The amount of rainfall is within normal" or "The amount of
rainfall is not within normal" based on the numbers.
3.
MONTH DISPLAY
The "Month" should be the actual name of the
month.
Use nested if statements similar to:
If (NumMonth == 1)
{
StringMonth = "January";
}
else
{
if (NumMonth == 2)
{
StringMonth
= "February";
}
else
{
//
continue with rest of months.