CSCI 1010 Programming Assignment #10 (Pass10)
Background: Computer Diet and Exercise (CSDE)
Congratulations Richard has raised your pay by 10% for service above and beyond the call!
The diet and exercise programs produced by CSDE are very popular and his Stimulator, Proteen Shakes, and Encourager sales are booming.
Richard is interested in having his elite software engineers design a program to support the sales representatives in doing order processing..
Purpose of Program
Use (pass by value and reference) function calls implemented in a menu based programming model.
Required Reading
Read chapter 6 from the Gaddis textbook and presentation slides from unit 10.
Exercise
Note: Some data input to this program and some program output depends on <your name>. If you do not use your name as required, points will be deducted for this assignment.
Function Prototypes and Global Constants
- Declare global constants
- SMALLSTIM=50.50;
- SMALLSHAKE=1.5;
- SMALLENCOURAGER=60.0;
- Declare the following function prototypes:
- int menu();
- void resetRegister(double&,int&,double&,int&,double&,int&);
- void calcItemCost(double&,int&,string,const double);
- void displayOrder(double,int,double,int,double,int);
Main Function
- Declare variables to hold the following fields.
- Type double: Stimulator, Shakes, Encourager. (initialized to zero)
- Type int: nStimulator, nShakes, nEncourager. (also initialized to zero)
- Note other variables may be needed.
- Output your Welcome message. Remember to use your name in the message.
- Enter your main logic loop (recommended Do While)
- Call function menu() – the menu function should display a menu as shown and use cin to input the user choice.
- Only valid selections should be accepted by your main logic function.
- If the choice selected==6, use a break statement to exit the do while loop.
- Use a switch statement to interpret the selection.
- Case 1- call resetRegister function to zero all variables. Function resetRegister must accept reference variables. resetRegister(Stimulator,nStimulator,Shakes,nShakes,Encourager,nEncourager);
- After calling the function use the break statement to exit the switch statement.
- Case -2 call calcItemCost to calculate the Stimulator sales
calcItemCost(Stimulator,nStimulator,”Stimulator”,SMALLPOP);
calcItemCost accepts two reference variables, a string literal and a cost constant.
- Case -3 call calcItemCost to calculate the Shakes sales
calcItemCost(Shakes,nShakes,”Shakes”,SMALLSHAKE);
calcItemCost accepts two reference variables, a string literal and a cost constant.
- Case -4 call calcItemCost to calculate the Encourager sales
calcItemCost(Encourager,nEncourager,”Encourager”,SMALLENCOURAGER);
calcItemCost accepts two reference variables, a string literal and a cost constant.
- Case -5 call displayOrder to output the sale receipt
displayOrder(Stimulator,nStimulator,Shakes,nShakes,Encourager,nEncourager);
displayOrder will accept variable passed by value.
- default call issue error message indicating invalid selection
- Complete the do while loop with } while(true);.
- After the do while loop exits, issue a “thank you for using…” message and return to the operating system.
MENU FUNCTION – int menu()
- Accept no parameters.
- Declare a variable to hold the choice or selection from the user – int choice;
- Output menu text
- Use cin to input choice
- Return choice to calling function.
calcItemCost Function – void calcItemCost(double &itemCost, int &nItems, string itemName, const double itemBasePrice)
- declare variables char size, and int count=0;
- prompt and input size code – s, m or l. for small medium or large.
- Validate input using a validation loop
- prompt and input number of items sold (1-10).
- Validate input using a validation loop
- Based upon the size, assign variable price the product of itemBasePrice and 1.20 for medium sized items and 1.30 times base for large items.
- Calculate sales as follows
- itemCost+=price*count*1.1; // (the 10% is the sales tax.
- nItems+=count;
- return
displayOrder Function – void displayOrder(double Stimulator, int nStimulator,double Shakes, int nShakes,double Encourager, int nEncourager)
- declare a variable total to hold the total sales.
- Compute the sum of Stimulator, Shakes, and Encourager sales.
- Use iomanipulators to format numeric output to fixed, setprecision(2), showpoint
- Output the report as shown below:
- After displaying report, pause program. Using cin.ignore(),cin.get();
- return.
resetRegister Function: void resetRegister(double &Stimulator, int &nStimulator,double & Shakes, int & nShakes,double & Encourager, int & nEncourager)
- function accepts reference 8 parameters.
- Assign zero to all variables
- Return to caller.
Example Structure
Notes and Comments
- Remember that the project name is pass10 and the C++ file name will be < your last name> with pass10. As an example the C++ filename will be programmerPass10.cpp.
- Make sure you have good comments throughout your program that include your name, CSCI 1010, Programming Assignment 10, the purpose of the program, and the main program logic.
- Create a flowchart from the pseudo-code above (see tasks above), submit your flowchart to the dropbox as lastnameflowchart… You may use Word, Visio, Raptor, or a scanned hand drawn flowchart.
- You need to compile the above program, and test the program with test case scenario used those mentioned in the section “Example input and output”.
- You need to submit the following to the D2L drop box: .cpp file <my last name>Pass10.cpp(e.g. programmerPass10.cpp).
If your program cannot be compiled (any error), zero points will be assigned.
Example Input and Output
The post CSCI 1010 Programming Assignment #10 appeared first on My Assignment Online.