Sample Questions - Decision Structures (6 days)

1. Write a program that will let you enter a number and will then tell you whether the number is odd or even.

2. Write a program that will let you enter 2 numbers and will then tell you which one was the smallest.

3. Write a program that will let you enter your age and will then tell you if you are old enough to vote.

4. Write a program that will let you enter 2 numbers and then a character (M, D, A or S) and will then give you the product, quotient, sum or difference.

5. Write a program that will let you enter a number and will then tell you whether the number was positive or negative.

6. Write a program that will let you enter your age and will then tell you whether you are young, middle aged or old.

7. Write a program that will let you enter 3 prices and will then figure out your discount and tell you the total cost. Discount rate is 10% if you spent over $100 , 5% if you spent less.

8. Write a program that will let you enter how many hours you worked and then a character to say if you are male or female and will then tell you how much you made for the week. (Females make $6.78 an hour, males $5.87)

9. Enter 3 numbers and print out the smallest.

10. Enter how many inches tall you and then print out short, medium or tall.

11. Enter 3 grades and then print out a message that you made honors or didn't make honors.

12. Enter 3 grades and print a message if you passed all 3 tests or didn't pass all 3 tests.

13. Enter 3 numbers and print out all the numbers are the same, 2 of the numbers are the same or none of the numbers are the same.

14. Write a program that will let you enter a name and will then print out the phone number for that person. It should work for 3 people. If the person entered is not one of the 3 people then print a message that that person is not on file.

15. Enter 3 sides of a triangle and print out scalene, isosceles or equilateral.

16. Enter 2 numbers and then enter Big or Small and it will print out the biggest or smallest number.

Enter a number : 12
Enter a number : 5
Enter Big or Small : Small
Smallest is 5

17. Enter a product (Hot Dog, hamburger or Soda) and th ecomputer will tell you the price.

Enter a product Hot Dog
Price is $2.55

18. Write a program that will let you enter a price and a number (a 1 , 2 or a 3). If a 1 is entered there is no discount, if a 2 is entered the discount is 10%, if a 3 is entered the discount is 20%. Print out final price.

Sample
Enter a price : 35
Enter a 1, 2 or 3 : 2
Final price is 31.50


19. Write a program that will let you enter a list price - then enter a word (great good, ok). It the great is entered they pay 70% of the list price, if the word good is entered they pay 80% of the list price, if they enter OK the cost will be 90% of the list.

20. Write a program that will let you enter your gender (M or F) and your height in inches and will then tell you whether you are tall, medium or short. Men are tall if over 72 iches and short if under 66 inches. Girls are tall if over 66 inches and are short if under 60 inches.

21. Write a program that will ask you to enter the cost of an item and will then ask you to enter how many of the items you bought, and will then tell you how much yiou owe.

22. Write a program that will ask you to enter a temperature, and will then ask you to enter a C or a F. If you enter a C then you will convert the Fahrenheit temperature entered to Celcius. If you enter a F then you will convert the Celcius temperature entered to Fanhrenheit. Formulas are
C = (F - 32) * 5/9
F = (c * 9/5) + 32

Ex.
Enter Temperature : 100
Convert to (F or C) : F
Temperature in Fahrenheit is 212



21. Enter R for Regular of P for Premium gas, enter number of gallons bought and it will tell you how much you owe. (Regular is $3.94 and Premium is 4.12 a gallon


HOME