Self-Test 2

Wed, Nov. 3, 2010


Before you start:

Create a directory for this SelfTest (call it SelfTest2, for example) and save your source code there.

Exercise 1:

In a new role-playing fantasy game players must design their character by picking a point value for each of three characteristics:

Write a program that asks for a name for the character and asks for a point value for each of the three characteristics. However, the total points must be less than 16. If the total exceeds 15, then 5 points are assigned to each characteristic.

Sample run:

Enter the name of your character: Chortle
Enter strength (1-10): 8
Enter intelligence (1-10): 4
Enter luck (1-10): 6

You have given your character too many points! Default values have been assigned:
Chortle [strength: 5, intelligence: 5, luck: 5]

Exercise 2:

Exercise 1 ignored the possibility that the user's input for the three variables might not be between 1 and 10.

Extend your program in such a way that it notifies the user in case at least one of the variables is not in the admitted range, and assigns the default value 5 to each variable.


When you are done with the exercise, get started on hw3.