I have created a program allows you to input the amount of items purchased, and then input the price of each item and the sales tax. It then creates a receipt which totals all the prices and sales tax.
Now I want to be able to list the items and their prices in the sales receipt as well. What would I have to do so lets say you pick 5 items and type in 5 prices and it give you the sales receipt, before it tells you the total, I want it to list the 5 items so looks like this:
Sales Receipt
Item 1: Price
Item 2: Price
Item 3: Price
Item 4: Price
Item 5: Price
**********
(rest of sales receipt)
Here is what I have so far:
I receive the following error:Code:#include <iostream> #include <iomanip> using namespace std; int main() { char rerun; do //The do-while for a program rerun option { // Declare variables: counter, items, sales items, sales total, sales tax, and grand total int items, count; int * price; double total, percent, g_t, tax; // Input information cout<<"How many sales items do you have? :"; cin>>items; price= new (nothrow) int[items]; if (price == 0) cout << "error"; else { for (count = 0; count < items; count++) { cout<<"Enter the value of the sales item. : $"; cin>>price[count]; total = total + price; } } cout << endl << endl; cout<<"Enter in the sales tax percentage. :"; cin>>percent; tax = total * (percent/100); g_t = tax + total; cout << endl << endl; cout << "********************************************" << endl; cout << "******** S A L E S R E C E I P T ********" << endl; cout << "********************************************" << endl; cout << "** **" << endl; cout << "** **" << endl; cout << "entered"; for (count = 0; count < items; count++) cout << price[count] << endl; cout << "** **" << endl; cout << "** **" << endl; cout << setiosflags(ios::fixed) << setprecision(2); cout << "** Total Sales: $" << setw(9) << total << " **" << endl; cout << "** Sales Tax: $" << setw(9) << tax << " **" << endl; cout << "** ----------- **" << endl; cout << "** Grand Total: $" << setw(9) << g_t << " **" << endl; cout << "** **" << endl; cout << "** **" << endl; cout << "********************************************" << endl; cout << endl << endl; cout<<"Do you want to run this program again? (y/n)"; cin>>rerun; } while (rerun == 'y' || rerun == 'Y'); system ("PAUSE"); return 0; } //End Main Function
How should I be writing it so that an operator is used on a pointer?salerec.cpp(33) : error C2111: pointer addition requires integral operand
Error executing cl.exe.
salerec.exe - 1 error(s), 0 warning(s)



LinkBack URL
About LinkBacks



