
276 CHAPTER 5 Flow of Control,Part 1: Selection
EXERCISES,PROBLEMS, AND PROJECTS
❑ If the year entered has four characters, just convert it to an int
and output it.
❑ If the year entered has neither two nor four characters, output
that the year is not valid.
52. Write a program that takes two words as input from the keyboard,
representing a user ID and a password. Your program should do the
following:
❑ If the user ID and the password match “admin” and “open,”
respectively, then output “Welcome.”
❑ If the user ID matches “admin” and the password does not
match “open,” output “Wrong password.”
❑ If the password matches “open” and the user ID does not
match ...