Assignment 5 

Due Monday, January 29 at 9:20am on Canvas

Assignment 5.1: Buying Pastries (10 pts)

  • Open a new C++ file called pastries.cpp
  • Add a block comment at the start of your program to include your name and section information:
* Jennifer Parrish
* M/W 9:30-11:20am

  • Imagine you just opened up a bakery called "C++ Pastries."
  • You want to create an online order form for customers to purchase your baked goods.
  • Write a program to collect a customer's order and then print the summary of their order to the screen.
  • Write four variables - 1 for each type of pastry
    • eclairs
    • bear claws
    • croissants
    • cupcakes
  • Name each of your variables according to correct naming conventions.
  • Write a cout statement welcoming the user to your store "C++ Pastries."
  • Write four cout statements asking them how much of each type of pastry they would like to buy.
  • Each cout statement needs to be followed by a cin statement to collect the information for the requested order. (four cin statements)
  • Finally, write a cout statement to print a summary of the customer's order to the screen.
  • Save your file as pastries.cpp and upload it to Canvas.
  • Your output should look identical the following (except the user input will vary).
  • Notice the blank lines. These are important, so don't forget to include them!

Welcome to C++ Pastries!
Allow me to assist you with your order.

Please enter the number of eclairs: 3
Please enter the number of bear claws: 5
Please enter the number of croissants: 9
Please enter the number of cupcakes: 0

You ordered the following:
3 eclairs
5 bear claws
9 croissants
0 cupcakes

Assignment 5.2: Costly Habits (10 pts)
  • One of the keys to financial well-being is to understand the impacts of our spending habits.
  • We all have little habits, such as buying coffee or snacks every day, that add up over time.
  • In this program we explore how much a habit will cost us, or a friend, by time we reach age 75.
  • Example Run: The input prompts and outputs of the program must look like the following for full credit, including the same order of input and wording of the output.
  • For the input shown you must get the same output. However, the output must change properly if the inputs are different.
  • Write a program that calculates the cost of a daily habit by the time you reach age 75. Because the amounts may be large, we want to see the cost in both dollars and millions of dollars.
  • For example, $75,000 is 0.075 million dollars.
  • Open a new C++ project called Habits with a file named habits.cpp
  • Ask the user for the following inputs (and no other input) in this order, as shown in the Example Run below:
    • age in years
    • habit cost per day
  • Assume the user enters valid integers for age and decimal numbers for habit cost per day.
  • Your program should then output the following:
  1. The amount of money the habit will cost the user in one year (hint: how many days in a year?)
  2. The amount of money the habit will cost the user by the time they reach 75. (hint: how many years until they reach 75?)
  3. The cost from #2 above in millions of dollars
  • Numbers may not display with exactly two decimal places, which is fine.

    Current age (years): 19
    Cost of daily habit: 10.75

    This year your habit will cost you $3923.75
    Between now and age 75, it will cost you $219730.0!
    Cost in millions of dollars is 0.21973!

  • Hint: Ignore leap years, and ignore that the user may be part way through the year.
    • For example, if the user enters age 50, assume there are 25 full years until he or she reaches age 75.
  • Hint 2: To get the cost in millions of dollars, divide by one million (how many 0s in a million?)
  • Hint 3: Assume the user is no older than age 75, and that the user enters correct data.
  • Submit habits.cpp when you are finished.