This program will give you more practice branching, calling standard library functions, looping and playing with character input's clever applications. (There may also be a chance to write your own functions -- to clean up the program and ease development -- to practice with randomness, or even to use more advanced input features. See the Options section below.)
The company you work for uses information about the current year's planned budget compared to the current year's expenditures to decide what next year's budget will be.
Write a program that helps the user -- prospectively a manager at the company -- determine the budget for the next year. You should gather from them both the budgetted amount for last year and the amount spent for last year. For each, the user may enter the currency units either in front or in back of the value. If they enter neither, you are to assume that currency is measured in dollars ($). Although it shouldn't happen, if they enter something in both places, you should be able to handle that, too.
Then calculate for them the percent of their budget that was used -- this may be over 100%. This percent should be rounded to the nearest whole percent. Finally, force their spending up to the next $100 and tell them that this figure will be their budget for the next year.
Make sure you print their results in a nice way. Use the currency unit they entered at the beginning (or $). Be sure to place this marker either in front or in back of the new budget just like they entered it. (If they didn't enter the units, place the $ in the front by default.) And always print two decimal places (even though we shouldn't have any change to report). Also print the percent of their budget that was used with a percent sign (%) after it.
As an example, you might have the program interaction look something like (the parts in blue are typed by the user):
$ budgetproj.out Welcome to the Budget Projection Program!!! What was your budget allotment last year? $1300.00 Fine, and how much did you spend last year? $1432.00 Thank you!! Calculating... Done. Last year you used up about 110% of your budget. Your budget next year will be $1500.00. Thank you for using the BPP!! Endeavor to have a fiscally fit day! $
Note how the percent rounded down but the new budget amount went up.
This assignment is (Level 4).
Budget Projection Menu 1) Project Budget for Next Year 2) fLip Coin for Rounding [NO] 3) Weight Distribution for budGet percentaGe [NO] 4) QuitThe first option (chosen by the user entering 1, P, p, B, b, N, n, Y, or y) acts as the program currently does. The second option (chosen by the user entering 2, L, l, C, c, R, or r) controls an option that determines how to round for next year's budget. When its state (indicated in the square brackets after the menu choice text) is NO, the program will round as indicated above. When its state is YES, the program act as described in the virtual coin toss option below. The default state will be NO. If the user choses this option, the state will change to YES. If the user choses this option again, the state will change back to NO. The third option (chosen by the user entering 3, W, w, D, d, G, or g) controls an option that determines if the percentage of the current expenditures taken as the basis for next year's budget should be uniform or weighted (see the virtual coin option and its follower below). The default state for this option is NO and chosing it will only toggle to YES if the coin option is YES. When the coin option is NO, selecting this menu option has no effect and should probably print a message to that effect. (Note that this program option subsumes the 'repeat as desired' option so you get credit for that option's level, too!) (This option does not subsume either the 'coin toss' option nor the 'weighted distribution' option, however. You can take those options and this option independent of one another. All of their levels will stack together.)
Percent Relationship to 100% | Message Displayed |
---|---|
> 100% | This overspending will bankrupt the company! |
== 100% | Way to keep your eye on the ball, Johnson! |
< 100% | Thanks to you, this company will be solvent for years to come! |