Assignment 03

Due: Friday, February 19, 2021, 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. We suggest you finish this program well ahead of the due time since you will have a test that same day. Having programmed this, you will also prepare yourself well for the test.

Background: Bart has been running his gambling ring for quite some time. The money has been rolling in and it’s been nice - Bart buys whatever skateboard, candy, or video game he wants. But Bart isn’t the type to settle down; Bart wants more. So, Bart devises a pl

  • option 5: This option will quit the program.

The menu of options is to be displayed after each choice is made until the quit option is chosen. 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 precede option 4; Bart's formula addresses that situation. All inputs that can be checked for validity ("input cleansing") should be.

Special Requirement: Since you now know the rudiments of functions in C++, you are required to use the following specified functions in your solution code:

  1. A function called greeting() that returns nothing but outputs an opening message to the user of the program. (After hw 3, you probably shouldn't do this anymore since a greeting message is really only one line of code and doesn't require use of a function.)

  2. A similar function called sign_off().

  3. A function named get_student_number() that performs the functionality described above for option #1. It will have no parameters, return a 7-digit integer, and repeatedly prompt/read in values from the user until a 7-digit integer is entered.

  4. A function named validate_student_number() that will be passed the student number entered under option #1 and return true if valid, false if not. This function is called when option #2 is chosen.

  5. A function that is called when option #3 is chosen, called input_assets(). It will prompt for and return the monetary value of assets of the user. It should have no parameters.

  6. A function that is passed user assets (assumed 0 if none have been entered), calculates and returns the BFA. You can think of a good name for this one, and what it should return and what parameters it should (or should not) have.

To help you out with this program, here is a pseudo-code for the program:

begin main

declare variables

greeting()

loop menu choice

present menu

read in choice

switch on choice

opt1

get_student_number()

flag num entered

opt2

validate_entered_number()

flag and announce results

opt3

input_assets()

opt4

calculate and return BFA with your appropriately named function

opt5

quit

end switch

end loop on menu

sign_off()

end main function

Note: This is not c++ code. It is pseudo-code; you turn it into c++. And, this is just one way to think about the program; there are others. Furthermore, we have left out many details, included some hints as to what you should include, left out much. It is your job to fill in the details and code it to work properly.

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.

As usual, if you have questions, don't hesitate to ask your instructor or Bart. Don't bother asking Krusty because he doesn't know anything!

1No, you aren't going to get extra points for this. Sometimes, you just have to do things because you want to.

There are no other options. Thus, the number 2555734 is that of a junior, and 1563320 is that of a freshman, while 394583 is invalid for multiple reasons. (Yes, we know, every student must change their student number every year is really stupid. But what do you expect from Krusty?)

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

Bart'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

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 re-prompt 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 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 BFA (Bart 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

an that works well within his expert demographic and is the most predatory, profitable sector: student loans. Since you did such a good job last time, Bart decides to hire you for this job as well. He's been hired by one of Springfield's town fathers, Krusty the Klown, to help at his new college. Your job is to write a program that will calculate for a student a “fair” loan package. Don’t worry too much about the interest, Bart will figure that out later (probably going to be above 50%, but we don’t need to know that…nor do the students).

So, Bart's plan is to base student loans on student number. That makes sense, doesn't it? You must know the following about student numbers at Springfield's own Krusty Regional University of Dietary Disaster (KRUDD). 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