CMSC 160
Fall 2018
08/30/2018
More with I/O  and Calculations
Due:  #1 and 2:  Tue, Sept 4 at 8am
#3 and 4:  Th, Sept 6 at 8am

Assignment:    (11 points)

1)  Limerick  (2 points)  (due Tue, Sept 4 at 8am)
Create a program that prints a limerick on the screen.     Hopefully you know what a limerick is, but if you do not, a quick synopsis:
  • 5 line poem
  • rhyming scheme AABBA
  • lines 1, 2, and 5 have 3 stressed syllables
  • lines 3 and 4 have 2 stressed syllables
Additional requirements:
  • Lines 3 and 4 should be indented 5 spaces from the other lines.
  • If you did not make up the limerick, be sure to attribute it during the display.
  • Remember that my young children may be in the room when I grade this, so keep it clean.
  • Be certain that there is a comment at the top of the file saying what the program does, who wrote the program, and anyone you received help from.
Handin:    handin  cmsc160 lablimerick   filename.cpp        < replacing filename.cpp with whatever you call your file> separator

2)  
Building desks.    (3 points)   (due Tue, Sept 4 at 8am)
Imagine a shop that builds desks using wooden boards.   Each desk requires 6 boards to build.

a) Write a program  that asks the user how many wooden boards they have.     The program should then report:
  • how many desks the user can build with those boards.
THINK ABOUT:  
  • What should the answer be if they type in 12 for the number of boards?  
  • What should the answer be if they type in 40 for the number of boards?
  • What should the answer be if they type in 5 for the number of boards?
GET THE PROGRAM TO WORK TO THIS POINT BEFORE PROCEEDING.
--------------------------------
b)
 Now, modify the program to ALSO print:
  • how many boards will be left over.
THINK ABOUT:  
  • What should the answer be if they type in 12 for the number of boards?  
  • What should the answer be if they type in 40 for the number of boards?
  • What should the answer be if they type in 5 for the number of boards?
GET THE PROGRAM TO WORK TO THIS POINT BEFORE PROCEEDING.
----------------------

c) Modify the program to also ask the user how much they wish to charge for a desk (a real number) and report how much money they will make if they sell all of the desks.   It is okay if your display does not have two decimal places.   Eg  $17.5    is okay instead of $17.50

Be certain that there is a comment at the top of the file saying what the program does, who wrote the program, and anyone you received help from.

Handin:    handin  cmsc160 labdesks   filename.cpp        < replacing filename.cpp with whatever you call your file>

separator

3)  MadLibs. (3 points)  (due Th, Sept 6 at 8am)
A "MadLib" is a story constructed by prompting someone for words in certain categories (adverbs, proper names, numbers, articles of clothing) and using them to fill in blanks in a template. Examples can be found on-line, for instance at the Wikipedia page on MadLibs.

Your task is to create a program that does MadLibs on the computer. Your program will ask for at least six things and then displays the story. At least one of the things must be used twice (or more) in the story.

Your story does not have to be particularly long, and it can be as surreal as you would like. Have fun with it. If you insist on using an existing MadLib, that is okay but not as fun. If you do this, be certain to attribute (in your comment AND in the output) where the MadLib came from.

As always, be certain that there is a comment at the top of the file saying what the program does, who wrote the program, and anyone you received help from.

Handin:    handin  cmsc160 labmadlibs   filename.cpp        < replacing filename.cpp with whatever you call your file>

separator
4)  Counting Steps.   (3 points)  (due Th, Sept 6 at 8am)
 In the days before Fitbits, people counted their steps.   Obviously, this was impractical for long runs/jogs.      One method sometimes used was to count the number of steps in your first minute and the number of steps in your last minute.   Averaging these would then be used as an average over the entire exercise and then estimate the number of steps.  This would be just an estimate, but it is what people did..  

My neighbor has taken up jogging, but has lost his Fitbit.  I have advised him to utilize the method described above.  Write a program that he can use when he gets back home in order to estimate his number of steps.    The program needs to ask:  how many steps in the first minute;   how many steps in the last minute;  length of the jog (in hours and minutes).     For instance, if he ran for 1 hour and 25 minutes, with 70 strides in the first minute, and 80 strides in the last minute, running the program may look something like this:
How many steps in the first minute?   70
How many steps in the last minute?   80
How many hours was your jog?  1
How many minutes over the hours?   25

Estimated number of steps:   6375

Be certain that you understand where this answer comes from.    If not, ask questions.
  
Think About for testing:
  • What is the estimated number of steps for a  1 hour 45 minute jog with 80 steps in the first minute and 85 steps in the last minute?
  • Come up with at least two other scenarios.
DO: Create a comment at the BOTTOM of the program that lists the scenarios for testing as well as the expected answers.

As always, be certain that there is a comment at the top of the file saying what the program does, who wrote the program, and anyone you received help from.

Handin:    handin  cmsc160 labsteps   filename.cpp        < replacing filename.cpp with whatever you call your file>