Skip Navigation
 

In Class Exercises

In-Class Exercise 3

  1. Write a program that allows the user to enter two numbers and displays one of two messages: "The first number is larger" or "The second number is larger".

  2. Modify the program 1. so that it can display a third message: "The two numbers are equal".

  3. Write a program that allows the user to enter any two numbers and always the displays the smaller number first, followed by the second number.

  4. Write a program that allows the user to enter 3 numbers and displays the largest of the three numbers.

  5. Write a program that allows the user to enter 2 numbers followed by a single character representing their desired operation: 'a' for add, 's' for subtract, 'm' for multiply or 'd' for divide. Perform the arithmetic operation that the user specifies.

  6. Modify program 5. so that it can accept either uppercase or lowercase letters.

  7. Write a program for a furniture company. Ask the user to choose P for pine, O for oak, or M for mahogany. Show the price of a table manufactured with the chosen wood. Pine tables cost $100, oak tables cost $225, and mahogany tables cost $310.

  8. Write a program that asks the user to type a vowel from the keyboard. If the character is a vowel, display "OK"; if it is not a vowel, display an error message. Be sure to allow both uppercase and lowercase vowels.

  9. The Bone Jour Dog Day Care Center charges clients a daily rate that is based on both the size of the dog and the number of days per month in a client's contract. The following table shows the daily rates.

   

 

 1-10 days per month

11 or more days per month

 under 10 pounds

 $12

$10

 10 pounds - under 25 pounds

 $16

$13

 35 pounds and over

 $19

$17

 

 
 
« go back|print