Assignment 8

Due Tuesday, May 8 at 9:20am on Canvas

Assignment 8.1: Pass or Fail? (10 pts)

  • Write a program to read in a user's test score and report back either "Pass!" or "Fail :(".
  • For this assignment, we will consider a passing score to be a value that is 60 or above, and a failing score to be below 60.
  • Name your file Pass.cpp.
  • The program should work identically to the code below and should use both an if and an else for full credit.

Enter your score: 60
Pass!

Alternately,

Enter your score: 100
Pass!

Alternately,

Enter your score: 59
Fail :(



Assignment 8.2: Jokes (10 pts)

Image of Mae West
Write a program to ask a user whether (s)he wants to hear a bad joke.
If the user indicates no, the program should quote Mae West, a classic Hollywood actress, who was famous for her amusing one-liners.

“Between two evils, I always pick the one I never tried before.”

-Mae West

If the user indicates yes, the program should print out the computer joke:


"Q: Why did the computer get cold?
A: Because it forgot to close Windows."


Your program should work identically to the example output below.

Note that your output should display the "" around the jokes.

Note that you are required to use exactly one if statement and one else statement to receive full credit on this assignment. (No else if needed!)

Submit joke.cpp to Canvas when you are finished.

Example Output:


Want to hear a bad joke (yes/no)? no
Okay. I will tell you a good one:

Between two evils, I always pick the one I never tried before.
- Mae West

Alternately,

Want to hear a bad joke (yes/no)? yes

"Q: Why did the computer get cold?
A: Because it forgot to close Windows."


Assignment 8.3: The Price is Right (10 pts)
  • Write a program that reads in a price as a string, and then outputs the price in dollars and cents.
  • Name your project PriceRight and create a C++ file called priceRight.cpp
  • For this program, you can assume that the user will enter in a price in either 10s or 100s of dollars. The price will never go above 999.99 or below 10.00.
  • Hint: read in the price as a string
  • Hint 2: Use the string functions (length and substr) to calculate the length of the String and then break the String into dollars and cents.
  • Hint 3: You will need one if and one else statement to solve this problem
  • Your program should work identically to the examples below:

Enter the price: 12.95
12 dollars and 95 cents.
  • Alternately,
Enter the price: 174.35
174 dollars and 35 cents.

  • When your program is complete, please upload it to Canvas.