Note: This lab assumes that you have completed lab 1, and that you know how to login to your account, and how to open, edit, save your files, as well as compile and run your programs. If you have forgotten any of these techniques, refer back to the lab 1 handout. Be sure to follow the directions very carefully. If you have any problems or questions, be sure to ask your instructor as soon as possible. Points will be deducted if the submitted programs do not have the appropriate comments included.
The program asks the user to enter a string and inputs one. Then it looks at the string and prints a message stating whether it is the empty string, a word, a number, or something else. For this lab, a string is considered to be a word if it starts and ends with a letter; it is considered to be a number if it starts and ends with a digit; and something else if it is not empty and it is not a word and it is not a number.
For example, here are several sample runs of the program you will write (user inputs are in bold):
Enter a string: Table
"Table" is a word
Enter a string: 2abl3
"2abl3" is a number
Enter a string: Tabl7
"Tabl7" is something else
Enter a string:
Empty string
To check whether a character is a letter or a digit, you can use the following methods:
The program asks the user to enter two integers. Then it asks three questions: what's the product of the two integers, what's the quotient of the two integers, and what's the remainder of the division of the two integers. It inputs the answers to each of the question from the user, tells the user whether the answer was correct or worng, and finally prints a message that depends on how many correct answers the user provided.
For example, here is a sample run of the program you will write (user inputs are in bold):
----------------------
MATH QUESTIONS
----------------------
Please enter an integer.
5
Please enter another integer.
3
Answer the following questions:
1. 5 * 3 = ?
17
Wrong!
2. 5 / 3 = ?
1
Correct.
3. 5 % 3 = ?
2
Correct.
You did OK.
You got 2 correct.
That's 66.66667%
Make sure that your program produces output exactly like the sample provided above and that it includes th epercentage of correct answers.
Here are the different messages that should be printed depending on the
number of correct answers:
| Correct Answers | Message |
|---|---|
| 0 | You did very bad. |
| 1 | You did poorly. |
| 2 | You did OK. |
| 3 | Good job! |