The exercise below will ask user enter
a number and display the information about "even"
or "odd". The two examples of
user and programmer interface are shown below. Blue
color - programmer. Red color -
user.
Please enter a number.
4
You entered 4.
4 is an even number. |
Please enter a number.
99
You entered 99.
99 is an odd number. |
I. Understand the problem.
INPUT: num.
OUTPUT: even
or odd?
2. Find the solution - how can a computer get the output after you
input a number?
HINT: If the
number can be divided by 2 evenly, it is even, otherwise, odd.

3. Translate the above flowchart into C++ language.
You have to break one sentence of output into
several items and use "<<" to separate
them. For example,
You
entered 4.
Two items are involved in. One is "You entered"
and the other is a number from NUM. Similar to the following
statement:
4 is an
even number.
Two items are involved in. One is a number in NUM
and the other is " is an even number." |
4. Debug your program. - Type in your program, compile, link and
run.
5. Write a notes for yourself. - Add a block comment and line
comments.
|