Homework 2

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 computes the test average for a course by doing the following:
  2. Sample run of program:
    Enter a grade: 87 Enter a grade: 89 Enter a grade: 92 Enter a grade: 93 Enter a grade: 86 Enter a grade: -1 Your average test score is 89.4 and your average letter grade is A.
  3. Write a complete C++ program that does the following:
  4. Sample run of program:
    Enter a positive integer input: 713402 There were 1 zeros, 1 ones, 3 prime digits amd 1 composite digits. The number had 6 digits.

    Another sample run of the program:
    Enter a positive integer input: -3287 Invalid input! Enter a positive integer: 2489 There were 0 zeros, 0 ones, 1 prime digits amd 3 composite digits. The number had 4 digits.
  5. Write a complete C++ program that does the following:
  6. Sample run of program:
    Enter two positive integers: 12 7 7 is the smallest and 12 is the largest. ************ * * * * * * *

    Another sample run of the program:
    Enter two positive integers: 5 -12 Invalid input! Goodbye.
  7. Write a complete C++ program that does the following:
  8. Sample run of program:
    Enter a positive integer with six digits or fewer: 67238 EEE OO

    Another sample run of the program:
    Enter a positive integer with six digits or fewer: 2348912 Invalid input! Goodbye.
  9. Write a complete C++ program that does the following:
  10. Sample run of program:
    Enter a positive integer with between two and five digits: 1 Invalid input! Enter a positive integer with five digits or fewer: 2432378 Invalid input! Enter a positive integer with five digits or fewer: 8432 The first digit of your input is 8 and the last digit of your input is 2.
  11. Write a complete C++ program that does the following:
  12. Sample run of program:
    Enter a positive integer: -21 Invalid input! Enter a positive integer: 17 The sum of all odd numbers from 1 through 17 is 81. The sum of all even numbers from 1 through 17 is 72.
  13. Write a complete C++ program that does the following:
  14. Sample run of program:
    Enter two integers. The second must be less than half the value of the first: 12 5 The numbers from 1 to 12 that are evenly divisible by 5 are: 5 10 The numbers from 1 to 12 that are not evenly divisible by 5 are: 1 2 3 4 6 7 8 9 11 12

    Another sample run of the program:
    Enter two integers. The second must be less than half the value of the first: 12 7 Invalid input! Goodbye.