Sample Design File for CMSC201 Spring 2003 Project 1


/********************************************** * File: design1.txt * Author: Carrie L. Desmond * Date: 3/3/2003 * Section: 103 * EMail: carrie1@umbc.edu * * Design for Project #1 **********************************************/ /********************************************** * Function: PrintGreeting * * This function displays a greeting to the user * * Inputs: None * Outputs: None **********************************************/ void PrintGreeting (void); /*********************************************** * Function: DisplayMenu * * This function displays the main menu choices * which will be 1 for Order Doughnuts, 2 for * Order Muffins or 3 to quit * * Inputs: None * Outputs: None **********************************************/ void DisplayMenu (void); /*********************************************** * Function: GetMenuResponse * * This function gets an integer from the user * between min and max, inclusive and returns * that valid integer as the menu choice. The * valid menu choices are 1, 2 and 3. I will use * a while loop to check the input and the loop * will continue until the user enters a valid * integer. * * Inputs: int min, int max * Outputs: int menu choice **********************************************/ int GetMenuResponse (int min, int max); /*********************************************** * Function: OrderDonuts * * This function completely handles placing an * order for doughnuts and returns the subtotal * (total before tax) for the order. To order * doughnuts I will first need to find out how * many people I am placing the order for. I * will make a call to GetNumPeople. Then I need * to find how many dozen of doughnuts I need. I * will make a call to FindDozens. I will then * calculate the # of dozens of each doughnuts I * need and display the output to the screen. * * Inputs: float price * Outputs: float subtotal **********************************************/ float OrderDonuts (float price); /*********************************************** * Function: OrderMuffins * * This function completely handles placing an * order for mini-muffins and returns the subtotal * (total before tax) for the order. To order * muffins I will first need to find out how many * people I am placing the order for. I will make * a call to GetNumPeople. Then I need to find * how mnay dozen of muffins I need so I will make * a call to FindDozens. I will then calculate * # of dozens of each muffins I need and display * the ouput to the screen. * * Inputs: float price * Outputs: float subtotal **********************************************/ float OrderMuffins (float price); /*********************************************** * Function: FindDozens * * This function calculates and returns the number * of dozens needed using the number of people and * their rate of consumption. If there are 3 or more * extra doughnuts/muffins the function will add * another dozen to the total dozens. * * Inputs: int people, float rate * Outputs: int dozens **********************************************/ int FindDozens (int people, float rate); /*********************************************** * Function: GetNumPeople * * This function gets the number of people from * the user guaranteeing the number is within the * range of min and max, inclusive and returns that * number. The valid number of people is between * 8 and 1000. * * Inputs: int min, int max * Outputs: int num_people *********************************************/ int GetNumPeople (int min, int max); /********************************************** * Function: CalculateTax * * This function calculates the amount of tax to * be charged from the subtotal and the tax rate * passed in. * * Inputs: float subtotal, float rate * Outputs: float tax *********************************************/ float CalculateTax (float subtotal, float rate); /********************************************** * Function: PrintTotals * * This function prints the subtotal, tax amount, * and the total on the bottom of every order with * decimals aligned. * * Inputs: float subtotal, * float tax, float total * Outputs: None *********************************************/ void PrintTotals (float subtotal, float tax, float total); The following is a list of constants I will be using based on the project description: #define MIN 1 #define MAX 3 #define MINPEOPLE 8 #define MAXPEOPLE 1000 #define DONUT 1 #define MUFFIN 2 #define QUIT 3 #define TAXRATE 0.05 #define DONUTPRICE 7.99 #define MUFFINPRICE 6.99 #define DONUTRATE 1.5 #define MUFFINRATE 2.5 #define DOZEN 12 /****************************************************** * MAIN * * In main I will start off the program making a call to * PrintGreeting. Then I will use a do while loop to do the * following: * * 1) Display the menu to the user * 2) Get a valid menu response * 3) Then use a switch statement of the menu choice that * is returned by GetMenuResponse. * 4) If the choice is Donuts, call OrderDonuts * If the choice is Muffins, call OrderMuffins * If the choice is Quit, print closing ordering program. * 5) If the choice is NOT Quit, the program will calculate tax * and print the totals. * * This order of events will continue until the user * decides to quit the program. ******************************************************/