COP 3014 Recitation - Week 2
(a) This program reads in a number from the keyboard
and stores it
into x. If the number is equal to 1, then a message is displayed on the screen,
otherwise no message is displayed on the screen. Copy this program and execute it
on your
machine.
(b) This program reads in a number from the keyboard
and stores it
into x. If the number is equal to 1, then a message is displayed on the screen
notifying that the number is 1. Otherwise a message is displayed notifying that the
number is not 1. Modify the previous program to match this one and execute it.
(c) What does this program do? Being able to describe
what a
program does can help you in writing programs also. Modify the previous program to
match this one and execute it.
(d) What does this program do? Modify the previous
program to match
this one and execute it.
(e) What does this program do? Modify the previous
program to match
this one and execute it.
(f) Write a new program that (1) reads in an integer named gradefrom the
keyboard and (2) displays
the letter grade corresponding to the integer. I.e., the program should display "A"
if the integer ranges from 90-100, "B" if the integer ranges from 80-89, and so
forth.
(g) This program reads in a character from the
keyboard and stores
it into option. It then displays the option that was selected. It uses
switch statements instead of if-else statements.
(h) Modify the program in (g) to include two additional options for '5' and '6'.
Program examples