
|
|
[
Academic Dishonesty Policy ::
Style Considerations ::
Style Examples ::
Statements Table ::
Exercise #5 ]

|
If you haven't attended last Lab please sign the
Cheating Policy Sheet.
|
Top

|
(See “C++ Style Guidelines” handout posted on Pr.Kelsey web page.)
- Use blank lines to separate set of related instructions.
- Liberally use clear and helpful comments.
- Make comments stand out - end of line (lined up) or blank line above comment.
- Type each statement on a separate line.
- Avoid running a statement over multiple lines.
- Avoid line splicing (line too long)
- Indent lines after a curly brace by the same amount until the end curly brace.
- Use whitespace in typing statements (cout<<"Hello all"; cout << “Hello all”;)
|
Top

|
Example 1
Example 2
Example 3
|
Top

|
|
Top

|
Write a program that reads in characters until the user enters the correct two-character sequence as a password. The password is cs. This password is used to open a door, let the user know when the door is open.
For example, the following sequences should all open the door:
cs
imacsmajor
ccs
But these sequences would not open the door and would require the user to keep inputting characters.
cas
sc
You do not need to prompt for each character one at a time. Your program should simply keep reading characters until the proper password has been entered. The program will just wait for the user to type in more characters if the password has not been entered correctly yet. If the password was entered correctly, output a statement saying the door has been opened and then the program will be finished.
Notice: Be sure to put all your information (login, lab section, …) at the top of your program. Your lab programs DO NOT get turned in electronically. I will come around and check you off individually.
|