CSIS 2610: Programming and Problem Solving 
Programming assignment 4: Functions and Modular Design

Due 4/9

Objectives

This assignment will give you practice with designing different kinds of functions, and implementing them as part of a large program.

Requirements

You are to write a program which computes a student’s total bill (including their tuition and fees), based on the number of credits they are taking and their year. The rules for this are as follows:

Tuition:

Part time (1 to 11 credits), freshmen and sophomores

$127 per credit

Part time (1 to 11 credits), juniors and seniors

$134 per credit

Full time (12 credits and above), freshmen and sophomores

$1524

Full time (12 credits and above), juniors and seniors

$1608

In addition, a surcharge of $69 per credit is added for any credits over 18.

Fees:

Part time (1 to 11 credits)

$32 per credit

Full time (12 credits and above)

$384

 

Your program is to do the following:

o       Prompt the user (in an informative way) for their class (freshman, sophomore, junior, or senior). Make sure that the user does enter a legal class.

o       Continuously prompt the user for whether they want to add another class. As long as they want to keep adding classes, do the following:

o       Prompt for the number of credits the course carries. Make sure that the user does enter a legal number of credits (that is, a number greater than 0).

o       Add that number to the total number of credits the student is taking.

o       Prompt the user for whether or not they want to see their current bill. If so, print it (see the next step for details).

o       Print the final bill. This should display the following information:

o       The total number of credits.

o       The tuition.

o       The fees.

o       The total bill (tuition + fees).

Here is an example to help you out:

1) Freshman
2) Sophomore
3) Junior
4) Senior
Which of the above are you: 5
That is not a legal class – enter a number between 1 and 4: 3
Enter the number of credits of the course you wish to add: 3
Would you like to see your current bill (y or n): y
------------------
Total Hours: 3
Tuition: $402
Fees: $96
TOTAL BILL: $498
------------------
Would you like to add another course (y or n): y
Enter the number of credits of the course you wish to add: 4
Would you like to see your current bill (y or n): n
Would you like to add another course (y or n): y
Enter the number of credits of the course you wish to add: 0
You must enter a positive number of credits. Try again: 5
Would you like to see your current bill (y or n): n
Would you like to add another course (y or n): y
Enter the number of credits of the course you wish to add: 3
Would you like to see your current bill (y or n): y
------------------
Total Hours: 15
Tuition: $1608
Fees: $384
TOTAL BILL: $1992
------------------
Would you like to add another course (y or n): y
Enter the number of credits of the course you wish to add: 5
Would you like to see your current bill (y or n): n
Would you like to add another course (y or n): n
FINAL BILL:
------------------
Total Hours: 20
Tuition: $1746
Fees: $384
TOTAL BILL: $2130
------------------

 

Design

Naturally, you are to write this program as a collection of very simple functions. You are *required* to implement and use separate functions for each of the following:

o       Prompting for and validating the student’s year.

o       Prompting for and validating the number of credits a course is worth.

o       Printing the current bill.

o       Computing the current tuition.

o       Computing the current fees.

o       Determining whether a student is full time or part time.

Exactly what these functions take as parameters and return is a major design decision on your part.

 

Another major design decision is determining where/when these functions will be called in your code (that is, whether it will be called by main or some other function, or possibly both). Note that you may be calling the same function (possibly with different parameters) from more than one place in your code.

Note that you are **NOT** to use any global variables in this program.

Reference Parameters (extra credit)

For up to 4 points extra credit, modify one of your functions to use reference parameters to get information back to the caller, rather than returning a value.

Implementation

You are strongly suggested to implement your code incrementally -- that is, write one function, insert calls to it in your code, and then test your code thoroughly (particularly the part that calls the new function!) before starting on the next. You might also want to temporarily put cout messages in your functions to make sure that they are being called correctly.

Finally, don't forget to put a function prototype for each function at the top of the file.

Documentation

As always, your code should be well documented; in this case, that means your functions should also be documented. Make sure to include a header at the top of each function, listing:

One way to approach this is to think about how you might explain the function to another programmer. This is an important part of your grade.

What to Turn In