I have to write a program that takes in a product name and cost, then outputs it and also outputs the total running cost, unless the user input was q. My teacher wants us to use multiple functions in our program and it seems like she even wants it for the total running cost which is where i'm having problems. it keeps giving me the error that my variable cost isn't an integral or enum data type so i can't use it, but I read in my book about enums and I just don't see how i would implement that there mostly, because of the if statement. Also, I did look through the forums, but i didn't find anything that worked for me.
#include <iostream>
#include <iostream>
#include <cstring>
#include <cmath>
#include <limits>
usingnamespace std;
float runningTotal(double,double);
char menuLoop();
void menu();
int main()
{
menu();
return 0;
}
double runningTotal(double *cost, double *multipleCost)
{
if(cost > 0)
{
multipleCost += cost; // here is where i'm getting my error
} // error: expression must have an integral or unscoped data type
return *multipleCost;
}
char menuLoop()
{
char userInput[20];
double cost, multipleCost = 0;
cin.get(userInput,'\n');
cin >> cost;
putchar(tolower(userInput[20]));
if (userInput[20] = 'q')
{
cout << runningTotal(&cost, &multipleCost) << '\n' << "Thank You for shopping with us\n";
}else {
cout << "The product: " << userInput << " and the cost: " << cost << '\n'
<< "Your running total is:" << runningTotal(&cost, &multipleCost) << endl;
}
return userInput[20];
}
void menu()
{
int cost;
cout << "Do one of the following\n"
<< "Input a product name and cost or to quit the program enter Q\n";
menuLoop();
}