Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Fill in the bolded areas to create two different outputs for the program: // com

ID: 3759968 • Letter: F

Question

Fill in the bolded areas to create two different outputs for the program:

// complete the following program
// test the program
// first letting the computer generate the input
// second letting user input only two sets of data
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <iomanip>
using namespace std;

const bool KEYBOARD = false;
ofstream Out("con");

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);

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 TOTALS that need an initial value
//taxableTotal=0;
nonTaxableTotal=0;


prepareOutput(Out);
if (!KEYBOARD) startRandom();
headings(Out); // for computer generated
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);
// headings(Out); // for keyboard input
printLine(Out,iNumber,qty,price,cost,taxable);
// accumulate
// ******* - taxable total
// ******** - nontaxable total

/*if(taxable)
taxableTotal=taxableTotal+cost;
else
nonTaxableTotal=nonTaxableTotal+cost;*/

} // ENDFOR
taxDue = getTax( taxableTotal );
//grandTotal=taxableTotal+nonTaxableTotal;
printTotal( Out,differentItems, grandTotal, taxDue);
} //ENDMAIN

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)
{
// ask the user
// OR
// computer will make NOT taxable if itemNumer is divisible by 5


// ask the user if he wants to say taxable or not say
//bool tax;

/*if (KEYBOARD)
{
cin>>tax;
return tax;
}
else if(itemNumber %5==0)
return false;
else
return true;*/
// if yes then whatever he says return true for taxable and false if not
//else check if(itemNumber % 5==0) to check divisibility by 5 if true return false as item is not taxable
// else return true

return true;//TRUE IS A TEMPORARY RETURN VALUE
}
int getQuantity(int num)
{
// ask the user
// OR
// computer will make a choice between 1 and 8

// ask the user if he wants to give quantity for the itemnumber num
// if yes then whatever he says return that  
// else take random number between 1 and 8 using random number generator and return it
// return (rand()%8 + 1);


return 1; //"1" IS A TEMPORARY RETURN VALUE
}
int getNumberOfSales(void)
{
// ask the user
// OR
// computer will make a choice between 1 and 15

// ask the user if he wants to give number of sales
// if yes then whatever he says return that
//else take random number between 1 and 15 and return that

//return (rand()%15 + 1);
return 4; //"4" IS A TEMPORARY RETURN VALUE
}
double getCost(int itemNumber, int count, double price)
{
//return count*price;
return 1.00 ; //"1" IS A TEMPORARY RETURN VALUE
}
double getTax( double sales)
{ // define a const for the sales tax rate - USE a rate of 0.0725
//calculate and return sales* the sales tax rate (here 0.0725);

return 1.00 ; //"1" IS A TEMPORARY RETURN VALUE
}
void printLine(ostream & w,int iNumber, int qty, double price,double cost, bool taxable)
{
w << "***Detail line*******" << endl; // print a "*" for the item which is
// not taxable
/* here check if(taxable)
then print normally all the details
else
print with *
*/

}

void printTotal( ostream & w,int loopCount, double grandTotal, double taxDue)
{
w << endl << endl <<"You owe 10.50 for 3 items " << endl; //DUMMY PRINTER LINE

w << endl <<" * indicates item was not taxable ." << endl;
}

void headings(ostream & w)
{
w << setw(10) << "item #" << setw(10) << "quantity" << setw(10) <<"price"
<< setw(10) << "cost" << endl << endl;
}

void prepareOutput(ostream & w)
{
w << setiosflags(ios::showpoint | ios:: fixed) << setprecision(2);
}

Explanation / Answer

#include <iostream>
#include <fstream>
#include <cstdlib>
#include <iomanip>
using namespace std;
const bool KEYBOARD = false;
ofstream Out("con");
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);
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

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote