Assignment 04

Due: Thursday, February 10, 2011, at noon, 100 points

For this assignment, you will submit a single C++ compilable file containing a program written in C++. By now you all know how to submit. Be sure that the file is in its own directory.

Background: Jerry G was really pleased with your work on the brush choosing software you wrote for him in the last assignment. He's decided to retain your services for additional programmng projects. In fact, Jerry's got a project for you already. He's decided to go to college and he needs your help. He got a work-study job in the Financial Aid office on campus and he's kinda worried about handling the job with the due diligence it deserves. He wants you to write a program to do his job for him so that he can engage in other activities .... well, so that the job is done right. Given a student number, his job is to calculate a fair and equitable financial aid package. Since Jerry really doesn't understand the phrase "fair and equitable", his formuli for computations are going to seem a bit off-beat, but you just do what he states and let him take the fall for it.

You must know the following about student numbers at his university. They are 7-digit, begin only with 1, 2, or 3, and the following level code must apply:

  • If the student number is abcdefg, then if ab is

    • 15, level is freshmen

    • 20, level is sophomore

    • 25, level is junior

    • 30, level is senior

    • 35, level is graduate student

There are no other options.

Specifications: Your program is to present a menu to the user. The menu should look like this and have these options:

Jerry's Financial Aid Calculatin' Program <-- you can come up with your own heading 1. Enter student number 2. Validate this number 3. Assets 4. Calculate financial aid package 5. Quit 6. Peace man

You are required to use the switch-case statement to implement decision branching to act upon each choice made. This is what you should make happen:

  • option 1: Prompt user to input a valid student number. At this point, accept any 7-digit number, but only 7-digit numbers (with the first digit not zero). Continue to reprompt if anything but a 7-digit number is entered. Optional:Give the user a maximum of 5 tries to get it right. If at that point they still can't get it right, output a snarky message about their future employment opportunities and terminate the program. 1

  • option 2: Validate the entered number as being a proper student number according to the format described above. That is, every student must be one of freshmen, sophomore, junior, senior, or grad. If the number entered is invalid, output an appropriate error message and restore the menu.

  • option 3: Prompt the user for his/her/its financial assets. Ok, since this is a basic program, you're not going to demand their FAFSA. Just prompt for a single value representing how much money the user's family has for educational purposes. You're to disallow negative inputs.

  • option 4: Your program is to calculate the Garcia Financial Aid formula:

    • With a student number abcdefg, Aid (in USD) = the product c * d * e * f * g, for students w/o Asset information = Assets + (c + d + e + f + g) * 4.3, for students with Assets entered

  • option 5: This option will quit the program.

  • option 6: I don't know what this is all about. Garcia put that there and it should be removed. (If you have extra time on your hands and you want it to do something cool for option 6, go for it. Otherwise, just ignore it.)

In addition, your program is to display an appropriate error message if the user chooses options 2 - 4 without having first entered a student number. It should do similarly if options 3 or 4 are chosen before option 2 has been chosen. Option 3 does not necessarily have to preceed option 4. Jerry's formula addresses that situation.

Since you will be outputting monetary values, you will want to use some "magic code" (until we explain it later in the semester) that will force the output of a decimal number to have exactly 2 figures after the decimal point. So when you try to output 3 1/2 dollars, it will come out as $3.50 instead of $3.5, which would look silly. Here's the code:

cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(2);

After this code, all floating point output will have exactly 2 figures after the decimal point.

When you submit: Enter the following options and information

  1. option 3

  2. option 2

  3. option 1, enter 25673, then 1693856

  4. option 2

  5. option 1, enter 1515153

  6. option 2

  7. option 3 and enter 1000

  8. option 4

  9. quit, or pick option 6 (if you have one) and then quit

Final Note: Don't underestimate the complexity and difficulty of this assignment. Start to work on it NOW .

As always, if you have questions, don't hesitate to ask your instructor or Nathan (in the lab Mon and Wed nights).

1Remember: in this course we will assume proper types have been entered by the user. So, if you prompt for a number, you get a number and not a string or char or peanut butter sandwich.