I'm trying to write a function to print out a subtotal but i can't seem to get it working please any advice would help. This is basically a calculator program that takes in the amount the user enters and keeps a running total until the user wants to stop.
void printheading();
void subtotal(calc inventory[], int count);
int main ()
{
printheading();
calc inventory[100];
int count=0;
char rerun;
float total=0;
do
{
cout<<"Please enter the DESCRIPTION: ";
cin>>inventory[count].description;
cout<<"Please enter the Amount: ";
cin>>inventory[count].amount;
subtotal(calc inventory[], count);
cout<<"Would you like to add more transactions?(N or Y) ";
cin>>rerun;
count++;
}
while (rerun == 'Y' || rerun == 'y');
return 0;
}
void subtotal(calc inventory[], int count)
{
float subtotal=0;
subtotal += inventory[count].amount;
cout<<"The subtotal is: "<<subtotal<<endl;
return;
}
void printheading()
{
cout << "********************CALCULATOR 1.0************************"
<< endl;
cout << "Welcome! " << endl;
cout << "This program computes the total for all your items."
<< endl;
cout << "You supply the information: Description, Amount."
<< endl;
cout << "The program will keep a running total for you until you want to stop."
<< endl;
cout << "**********************************************************"
<< endl;
cout <<"Let's get started ..." << endl;