Lab 6

The purpose of this lab is to help you learn to use if-then-else statements.

When you finish this lab you should have constructed examples of if, if-then-else, and compund if-then-else statements.

If

Write a program that reads in a person's name (first, middle, last). After you read each name, ask the person if you read it right, and if not, give them another chance to enter that name (just one).

Use a getline when entering the names so that they can enter an empty string if they wish.

if then else

Check to see if their first name is part of their last name, if it is, print out a string telling them that this is the case, if not, print out a message stating that it is not so.


(if the name is Dave Davidson)

Did you know that Dave, your first name, is part of Davidson your last name?

(If the name is Bob Davidson)

Did you know that Davidson, your last name, does not contain Bob, your first name?

Nested If then else

Print out the names in order. This is trickey, but you can do it with nested if statements. Don't make any compund conditions.

Compound

Finally, look at the first name, print a message baised on the following table and the length of the name.

Message: Your name has XXXX letters. (XXXX is from the table below)

Length Message
< 4 very few
4 four
5 five
6 six
7 seven
> 7 very many
So if the name is Robert, the message is

    Your name has six letters.

When you are finished, make sure that you document your program and email it to dbennett@edinboro.edu.