Assignment 01

Due: Friday, Jan. 29, 2021 at noon 100 pts.

For this assignment, you will submit a single C++ compliable file containing a program written in C++.

Background: Bart is an exceptional schemer. Although his grades aren’t great, when he wants something, he really puts his mind to it. What Bart wants right now is money, cold hard cash. So, Bart does what any other student would do, he sets up a gambling ring inside of Springfield Elementary School. What’s the first thing every good gambling ring has? Food and drinks…of course, of the non-alcoholic type. Everybody knows a good amount of sugar gets people gambling more. However, we can’t have too much sugar as they will get sick, throw up, or worst-case scenario Springfield becomes the unhealthiest school in the world and they take away the school’s saltshaker.

Bart has enlisted your help as a software developer to make a program that estimates the amount of sugar needed for the day in the gambling ring.

Specifications: Your job is to write a program that finds the optimal number of pounds of sugar needed to keep the gamblers going. To calculate this, you will have to take into account:

  • The number of people coming to the gambling room.

  • The average individual weight of the gamblers.

  • The average whole number (an integer) of pounds of sugar consumed per week in Springfield. That well-known value currently stands at 2 lbs. (Disgusting, isn't it! But fear not, these are cartoon characters. Real people would never behave that way.)

  • The SELM (Springfield Elementary Lunch Money) index, which changes day to day, and is a reflection of how much lunch money kids have. However, as we state below, it is added in only if there are more than five people gambling.

  • Bart’s gut feeling, a constant based on Bart’s excellent business sense to estimate how much sugar the gamblers feel like they’re taking in that day. This value has roots completely unrelated to science, but most scientists in Bart's bedroom will say it is .... 20....yeah, that's good. We'll go with that.

After extensive research by Bart (mostly over-dosing on sugar and passing out), he has found the perfect formula:

Pounds of Sugar = #people * (avgWeight * (avgSugarConsumption/gut feeling) + SELM)

Note: The SELM is only included in the calculation if there are more than 5 people in the gambling room.

Unfortunately, Bart’s associates aren’t so bright (like Ralph), so they need a different unit of measure to understand how much sugar is needed. Hence, we will convert the pounds of sugar to a unit everyone else will understand, the number of bottles of Duff Soda. There are 3 pounds of sugar in a bottle of Duff Soda (it doesn’t say it on the label but it’s true). If we need 6 pounds of sugar, we will need the equivalent of 2 bottles of Duff Soda. Since the associates don’t understand decimals (they’re in elementary school, give them a break), you’ll have to round the numbers down as well, and display the number of bottles as a whole number. For example, if we need 23 lbs. of sugar, we will need 7 bottles worth of Duff Soda.

Your program will need to begin by prompting for, and reading in, 3 numbers from the user of your program: 1) the number of people; 2) their average weight; and 3) the SELM index for the day. Once you have calculate the correct amount of sugar and the correct number of Duff Sodas, output the results. Your prompts for input should be clear and concise; your output should be easy to read. This means we don’t want to see output like:

20

2

There are no explanations of what these numbers are! Better output might look like:

....Or something like that.

Note: You are NOT to use the if or if-else statements (or any other c++ constructs we have not yet covered) in this programming assignment. You are going to need to code a "decision", though. This little fact will help: in c++, an expression such as (x > y) evaluates to a boolean value.

Remember: When writing code:

  • Declare your variables with the APPROPRIATE type.

  • Use meaningful variable and constant names. Don’t just copy any variable/constant names we might have used in this assignment. What is written above is an assignment statement, not code. You write the code; hence you name your variables. Think carefully about what you are doing.

  • Use proper spacing for indentations.

  • Use constant declarations where appropriate.

  • Include the comment block at the head of your file.

  • Comment code that needs it.

  • Be literate in your welcoming/signing-off messages and prompts and output.

When you submit your assignment, remember to upload your assignment to the corresponding repository in gitlab and remember to push your work after committing. It is also a good idea to run you code on the school machines via vpn and putty because those are the machines we will be grading on. We will not take “it ran on my machine” as an excuse for your code crashing.

Welcome to Bart's Sugar Monster Calculator

Please enter the following:

Number of people gambling: 6

Their average weight: 150

Lunch money index: 3.51

Thanks. What you need is....

111.06 lbs. of sugar is needed for the day

This is equivalent to 37 bottles of Duff Soda

....You have been using another awesome Bart-SoftTM product. Have a nice day.