Question
1. You are given a starter program 2. You will need to complete the program code 3. You will then test your program two ways:
1. You are given a starter program 2. You will need to complete the program code 3. You will then test your program two ways: a. using keyboard input for the data b. letting the computer generate the input for the data The following are some comments to help you complete the project 1. const bool KEYBOARD = false; if true the input is from the keyboard, if false the computer generates the data 2. ofstream Out("con"); this statement controls the location of you programs output 3. The following is a list of the functions you will use and write int getNumberOfSales(void); int getItemNumber(void); double getPrice(int itemNumber); bool isTaxable(int itemNumber); int getQuantity(int itemNumber); double getCost(int itemNumber, int count, double price); double getTax(double sales); void printLine(ostream & w,int iNumber, int qty, double price,double cost, bool taxable); void printTotal(ostream & w, int loopCount, double grandTotal, double taxDue); void headings(ostream & w); void startRandom(void); void prepareOutput( ostream & w); 4. In your starter program skeleton is the main, driver program you will use: void main() { int differentItems, // Number of items to purchase iNumber, // Item number code qty; // Number of a particular item purchased double price, // Price of a particular item cost, // The cost of the item purchase = price * qty taxableTotal, // Total of all taxable purchases nonTaxableTotal, // Total of all nontaxable purchases taxDue, // Tax due on the taxable total grandTotal; // Sum of taxableTotal, nonTaxableTotal bool taxable; // Flag to indicate if the item is taxable // -- Initialize ONLY those variables that need an initial value supply their code at this point prepareOutput(Out); if (!KEYBOARD) startRandom(); headings(Out); // for computer generate differentItems = getNumberOfSales(); for( int i = 0; i < differentItems ; i++) { iNumber = getItemNumber(); qty = getQuantity(iNumber); price = getPrice(iNumber); cost = getCost(iNumber, qty, price); taxable = isTaxable(iNumber); // at this point write the C++ statements call the headings function if you are using keyboard input, the headings will show up on cout and will be the printLine function output will show up directly underneath of the headings // headings(Out); // for keyboard input MODIFY THIS CODE printLine(Out,iNumber,qty,price,cost,taxable); // at this point write the C++ statements to accumulate the taxable total and the nontaxable total // accumulate // ******* - taxable total // ******** - nontaxable total } // end for taxDue = getTax( taxableTotal ) ; printTotal( Out,differentItems, grandTotal, taxDue); } // end main 5. Below are the functions used in Project 2. Some of the functions are already written. Other functions contains only a function stub. Those functions you will need to write according to the specifications given. void startRandom(void) { int seed; cout << "Enter seed value for random number generator: "; cin >> seed; srand(seed); } int getItemNumber(void) { // item number should be a 4-digit integer int num; if (KEYBOARD) { cout << "Enter item number: "; cin >> num; } else num = rand() % 9000 + 1000; return num; } double getPrice(int num) { // price should be between .10 and 10.09 double price; if (KEYBOARD) { cout << "Enter price for item " << num << " : "; cin >> price; } else price = double (rand() % 1000 + 10 ) / 100; return price; } bool isTaxable(int itemNumber) { // STUDENT Write the code for the isTaxable function supply their code at this point // ask the user // OR // computer will make NOT taxable if itemNumer is divisible by 5 return true; // Function STUB - remove this code once your function is written } int getQuantity(int num) { // Write the code for the getQuantity function Students will supply their code at this point // ask the user // OR // computer will make a choice between 1 and 8 return 1; // Function STUB - STUDENT remove this code once your function is written } int getNumberOfSales(void) { // Write the code for the getNumberOfSales function Students will supply their code at this point // ask the user // OR // computer will make a choice between 1 and 15 return 4; // Function STUB - remove this code once your function is written } double getCost(int itemNumber, int count, double price) { // STUDENT Write the code for the getCost function Students will supply their code at this point NOTE: For your solution the parameter itemNumber is not needed If there was a table of itemNumbers that were on sale, then the parameter itemNumber would be used in the code return 1.00 ; // Function STUB - STUDENT remove this code once your function is written } double getTax( double sales) { // STUDENT Write the code for the getTax function Students will supply their code at this point // define a const for the sales tax rate - USE a rate of 0.0725 return 1.00 ; // Function STUB - STUDENT remove this code once your function is written } void printLine(ostream & w,int iNumber, int qty, double price,double cost, bool taxable) { // STUDENT Write the code for the printLine function Students will supply their code at this point // Function STUB - STUDENT remove this code once your function is written w << "***Detail line*******" << endl; // print a "*" for the item which is // not taxable }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started