A3: Conversions

On This Page


Overview

This assignment calculate how much soda a dieter can drink without dying. During this assignment, you will:

  • Input strings and numbers from a user
  • Convert between different units of measurement
  • Display the results of calculations

Background Information

A government research lab has concluded that an artificial sweetener commonly used in diet soda will cause death in laboratory mice. A friend of yours is desperate to lose weight but cannot give up soda. Your friend wants to know how much diet soda it is possible to drink without dying as a result.

Specifications

Write a program to calculate how much soda a dieter can drink without dying. The input to the program is the amount of artificial sweetener needed to kill a mouse, the weight of the mouse, and the weight of the dieter. To ensure the safety of your friend, be sure the program requests the weight at which the dieter will stop dieting, rather than the dieter's current weight.

Sample Operation

  • The program prompts the user and allows them to enter the following information:
  • Enter the dieter's name: Ed Parrish
    Enter the target weight of the dieter in pounds: 175
    Enter the weight of the mouse in grams: 30
    Enter the lethal dose for the mouse in grams: 100
    
  • The information that the user enters is shown in italics in the above example.
  • After collecting the information, the program calculates and displays the following information:
  • For dieter: Ed Parrish
    Dieter's target weight: 175 pounds
    Lethal dose in grams of sweetener is: 264594
    Lethal number of cans of pop: 755983
    

Additional Specifications

  1. The name of the source code file must be sweetener.cpp
  2. Your program must work for any input values and not just the ones shown in the Sample Operation.
  3. Assume that diet soda contains one-tenth of 1% artificial sweetener. You may want to express the percentage as the double value 0.001.
  4. If you weigh a full can of soda and subtract the weight of an empty can you will see that the weight of the liquid is about 350 grams.
  5. Assume that the lethal dose for a mouse is directly proportional to a lethal dose for a human being.
  6. The program must accept the weight of a person in pounds and the weight of a mouse in grams. Note that 1 lb. = 453.59 grams. A mouse usually weighs between 15 and 40 grams.
  7. Remember to include a file comment block.
  8. Use a variable declaration with the modifier const to give a name to all numbers. Do not use magic numbers.
  9. You must ask for the information in the same order as shown in the Sample Operation
  10. The output must be like the sample output shown above with similar labels for the values reported.
  11. Note that you will need to use getline() for input of the dieter's name.

Extra Credit

The following are worth extra credit points:

  1. Use pair programming. (1 point)
  2. Add an extra calculation at the end of program that reports how many years it will take to drink a lethal dose at 15 cans per day and 365.25 days per year. (1 point)
  3. Years to lethal dose: 137.985
    

    Do NOT ask for the number of cans or days -- these are constant values.

Make certain that your README.txt file describes any extra credit attempted.

Grading Criteria

The instructor will evaluate your assignment using the following criteria. Each criteria represents a specific achievement of your assignment and has a scoring guide. The scoring guide explains the possible scores you can receive.

Some scoring guides have a list of indicators. These indicators are a sign of meeting, or a symptom of not meeting, the specific criterion. Note that a single indicator may not always be reliable or appropriate in a given context. However, as a group, they show the condition of meeting the criterion.

For information on grading policies, including interpretation of scores, see the course information page.

Program Compilation

  • 4: Source code compiles with no errors or warnings
  • 2: Source code compiles with warnings
  • 0: Does not compile or wrong file turned in

Functionality

  • 10: Demonstrates mastery of the assignment
    • Has extra features or demonstrates techniques beyond the assignment
    • Applies concepts from the lesson(s) appropriately
    • Meets all specifications (see above) with particularly elegant solutions
    • No errors encountered during operation
  • 8: Has all the functionality expected of the assignment
    • Demonstrates many techniques from the lesson
    • Meets all specifications (see above)
    • Implementation seems more complicated than necessary.
    • May have one minor error
  • 6: Has most of the functionality expected of the assignment
    • Demonstrates some techniques from the lesson
    • Meets all but one of the specifications (see above)
    • Implementation seems excessively complicated.
    • May have 2-3 minor errors
  • 4: Has some of the functionality expected of the assignment
    • Demonstrates some techniques from the lesson
    • Meets at least 1/2 of the specifications (see above)
    • Implementation seems excessively complicated.
    • May have more than 3 minor errors
  • 2: Serious functional problems but shows some effort and understanding
    • Meets less than 1/2 of the of the specifications (see above)
    • Has a major error or many minor errors
    • Implementation seems very convoluted
    • Demonstrates few techniques from the lesson
  • 0: Does not execute or no specifications met

Programming Style

  • 4: Code is well-documented
    • Name, date, and program description in file comment block
    • Follows specified format for file comment block
    • Proper use of spaces around operators
    • No tab characters are present in the source code
    • As described in How To Document and Organize C++ Code
  • 3: Code has minor documentation errors
    • Has 1 documentation error
  • 2: Code has some documentation errors
    • Has 2-3 documentation errors
  • 1: Code has many documentation errors
    • Has more than 3 documentation errors
  • 0: No apparent attempt to document code

REAME.txt File

  • 2: README.txt file submitted with specified information included
  • 1: README.txt file submitted but some information was missing
  • 0: No README.txt file submitted

Maximum Score: 20, plus extra credit

What to Turn In

Submit your assignment following the instructions for homework. Include the following items for grading:

  1. README.txt file
  2. sweetener.cpp

You must submit all the files needed to make your assignment function properly. Do not assume that the instructors has any files unless explicitly stated by the instructor. Your assignment must work as submitted.

Home | WebCT | Announcements | Day Schedule | Eve Schedule
Course info | Help | FAQ's | HowTo's | Links

Last Updated: October 04 2005 @19:41:34