Homework 1

Choose FIVE of the following seven problems to submit as homework. If you submit fewer than five problems, I will give you partial credit for the problems you do submit.

Each problem must be submitted as its own .cpp file. Grading for each problem is as follows:

If two or more people submit copies of the same work, every person submitting the copied work will get a 0 for the entire homework.

  1. Write a complete C++ program that does the following:
  2. Sample run of program:
    What is your name? Cathy What is your height in inches? 66 What is your age? 24 Hello, Cathy. Your age in days is 8760. Your height in feet and inches is 5 feet 6 inches.
  3. Write a complete C++ program that does the following:
  4. Sample run of program:
    Enter two integers: 34 27 When 34 is divided by 27, the quotient is 1 and the remainder is 7 The precise result is 1.25926
  5. Write a complete C++ program that does the following:
  6. Sample run of program:
    Enter your temperature in Fahrenheit: 98 Your temperature in Celsius is 36.6667 You don't have a fever. Go study.

    Another sample run of program:
    Enter your temperature in Fahrenheit: 100 Your temperature in Celsius is 37.7778 You have a fever. Drink lots of liquids and go to bed.
  7. Write a complete C++ program that does the following:
  8. Sample run of program:
    Enter a two- or three-digit number: 7894 You are not playing nicely.

    Another sample run of program:
    Enter a two- or three-digit number: 23 The leftmost digit is 2

    Another sample run of program:
    Enter a two- or three-digit number: 489 The middle digit is 8
  9. Complete both parts of this problem:
    1. Convert each of the following mathematical formulas to C++ expressions:
    2. Write a complete C++ program that does the following:
    3. You only need to submit the completed C++ program. You do not need to separately submit part a.
    Sample run of program:
    Enter three integers: 2 43 17 3 * 2 = 6 3 * 2 + 43 = 49 (2 + 43) / 7 = 6.42857 (3 * 2 + 43) / (17 + 2) = 2.57895

    Another sample run of program:
    Enter three integers: 87 56 24 3 * 87 = 261 3 * 87 + 56 = 317 (87 + 56) / 7 = 20.4286 (3 * 87 + 56) / (24 + 2) = 12.1923
  10. Write a complete C++ program that prompts the user for the time (two integers; hour and minute) and whether it is AM or PM.
  11. Sample run of program:
    Enter the current time. Hour: 7 Minute: 43 AM or PM? AM It's not time to eat.

    Another sample run of program:
    Enter the current time. Hour: 5 Minute: 30 AM or PM? PM Time for dinner!

    Another sample run of program:
    Enter the current time. Hour: 8 Minute: 37 AM or PM? PM Time for evening snack!
  12. Write a complete C++ program that does the following:
  13. Sample run of program:
    Enter your birth month: 3 Enter your birth day: 17 Enter your birth year: 2004 You were born in spring or summer. You were born in a leap year.

    Another sample run of program:
    Enter your birth month: 10 Enter your birth day: 1 Enter your birth year: 2003 You were born in fall or winter. You were not born in a leap year.