Assignment complete but needs subtle change. Please take a look

This is what my teacher had to say:

This is pretty good but not quite complete. You don't display the intermediate values like the assignment requires. You can fix that with out much trouble. Of course the display will be mixed up with the bad inputs. Give it a try and see what you can come up with.

What do i need to fix??

#include <iostream>
#include <iomanip>

using namespace std;
//prototypes

double get_item(char[]);
double get_discount(double);
double get_tax(double);
char coError_check();
void display_total_each_item(char[], double);
const double tax = .0825; //8.25% tax
int main()
{
cout << "Welcome to SHOP SOLUTIONS";//intro
cout << "\nThis program will calculate your total cost." << endl;//intro
cout << "Please press ENTER to begin\n\n" << endl;
cin.ignore(2000, '\n');



char checkout;//For exiting the do loop with 'q' or 'Q'
double total_cost_cal = 0.0;//accumilated here for the final cost
do{
char item_name[40];
double item_price_head;
item_price_head = get_item(item_name);//get name for item. get cost & quantity for each item, multiply with one another
item_price_head = get_discount(item_price_head);//give discount for item
item_price_head = get_tax(item_price_head);//tax for any item that applies for it
/*accumilator*/total_cost_cal += item_price_head;//accumilator which keeps track for absolute final cost
display_total_each_item(item_name, item_price_head);//cout display item's total cost
checkout = coError_check();//function for 'q' 'Q' error check
}while(!(checkout == 'q'));

cout <<"\nYour total cost is: $" << total_cost_cal;//total cost from accumilator

cout <<endl;
system("pause");
return 0;
}
/*******************************************************************************
************************SUB FUNCTION*******************************************/ /*
void GET_ITEM_NAME()
{
cout << "\nName:\t\t";
cin.getline(item_name, 40);//get item name from global veriable
return;
}
/*******************************************************************************
************************SUB FUNCTION*******************************************/
double get_item(char item_name_test[])
{
double item_quantity;
double item_price, total_item_price;

cout << "\nName of Item:\t\t";
cin.getline(item_name_test, 40);


do{//error check for item price entry (negative numbers)
cout << "Price for 1:\t$";
cin >> item_price;

if(item_price < 0)
cout << "Invalid entry. Negative number. Please only enter a positive number\n";
}while (item_price <= 0);

do{//error check for quantity entry(negative numbers)
cout << "Quantity:\t";
cin >> item_quantity;
if(item_quantity < 0)
cout << "Invalid entry. Negative number\n";
}while (item_quantity <0);

total_item_price = item_price * static_cast<int>(item_quantity);//calculate item cost so far
return total_item_price;//return item cost so discount can be applied
}
/*******************************************************************************
************************SUB FUNCTION*******************************************/
double get_discount(double item_2price)
{
double discount, discount_final, total_item_2price_;
do{// error check for discount . cant be less than 0 or more than 100%
cout << "Discount %:\t";
cin >> discount;
if(discount < 0)
cout << "Invalid Entry. Negative numberl Only Positive Numbers allowed\n";
else if(discount > 100)
cout << "Invalid Entry. 100% max\n";
}while(discount < 0 || discount >100);
discount_final = item_2price * (discount/100);//calculate discount
total_item_2price_ = (item_2price - discount_final);//calculate discount
return total_item_2price_;//return item cost so tax can be applied
}
/*******************************************************************************
************************SUB FUNCTION*******************************************/
double get_tax(double item_3price)
{
char taxable;
double total_item_3price;

cout << "Taxable?(Y/N)\t";
do{//error check for tax. if it's not 'y' or 'Y' or 'n' or 'N'.
cin >> taxable;
if(!(taxable == 'n' || taxable == 'N' || taxable == 'y' || taxable == 'Y'))
cout << "Invalid input. enter Y for yes or N for no";
}while(!(taxable == 'n' || taxable == 'N' || taxable == 'y' || taxable == 'Y'));

if(taxable == 'n' || taxable == 'N')
return item_3price;//if no, dont apply tax , and just return the value that was entered into the function
else if(taxable == 'y' || taxable == 'Y')//if yes, apply 8.25% tax
total_item_3price = item_3price + item_3price * tax; //can be rewritten as===> item_3price += item_3price(tax) but will have to return item_3price from function
return total_item_3price;//return item total price to display to user.
}

char coError_check()
{
char checkout_sub;//for exiting the do loop with 'q' or 'Q'
do{//an error check for checkout variable

cout << "\nENTER Q to checkout or ENTER to continue:\t";
cin.ignore(2000,'\n');
cin.get(checkout_sub);
if(checkout_sub =='q' || checkout_sub == 'Q')
return 'q';
else if(checkout_sub == '\n')
return 'z';
else
cout <<"invalid input. Please Re-Enter selection:\t";
}while(checkout_sub != 'q' || checkout_sub != 'Q' || checkout_sub != '\n');
}
/*******************************************************************************
************************SUB FUNCTION*******************************************/
void display_total_each_item(char item_name_test_2[], double item_price_sub)
{
cout << endl;
cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";//formatting for screen display
cout << endl;
cout << "Item name: " << item_name_test_2;
cout << endl;
cout << fixed << setprecision(2);//set precision to 2 for money value.
cout << "Item price: $" << item_price_sub;
cout << endl;
cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
return;
}


/*
Welcome to SHOP SOLUTIONS
This program will calculate your total cost.
Please press ENTER to begin




Name of Item: Steak
Price for 1: $-75
Invalid entry. Negative number. Please only enter a positive number
Price for 1: $2.50
Quantity: -9
Invalid entry. Negative number
Quantity: 5
Discount %: -4
Invalid Entry. Negative numberl Only Positive Numbers allowed
Discount %: 10
Taxable?(Y/N) Y

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Item name: Steak
Item price: $12.18
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ENTER Q to checkout or ENTER to continue:

Name of Item: Tuna
Price for 1: $.78
Quantity: 5
Discount %: 0
Taxable?(Y/N) N

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Item name: Tuna
Item price: $3.90
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ENTER Q to checkout or ENTER to continue: Q

Your total cost is: $16.08
Press any key to continue . . .
*/

My guess on what intermediate values the teacher is referring to, without seeing the original assignment, is you don't list the individual pricing and quantity along with the item name and price, something like:

~~~~~~~~~~~~~~~~~~~
Item name: Steak
Item price: $2.50
Quantity: 5
Discount: $1.25
Tax: $0.93
Total Price: $12.18
~~~~~~~~~~~~~~~~~~~

The assignment may want the discount in percent though. It may want the total before and after tax. It may not want the Quantity. It all depends on what the assignment requests for intermediate values (or, if it's ambiguous, then just provide the typical intermediate values I listed above).
Topic archived. No new replies allowed.