Hi. I'm new to programming, and I'm participating in a video course on C++. In it, there is a challenge to create a cash register program. It is not yet finished, as I still need to create a change calculator. But, I am currently recieving the following errors (note: I currently don't have access to a computer so I'm using a mobile C++ compiler and I cannot see the full error):
26 19 invalid '!=' at end of declar(ation???)... (Line in if statement of askForItem)
26 30 expected identifier (same as last line)
41 3 no matching function for c(all to???)... (Line that calls askForItem)
So, am I doing something wrong, or is this mobile compiler giving a false error?
Also, sorry for the poor spacing/formatting, my mobile compiler doesn't have a Tab option.
#include <iostream>
usingnamespace std;
double getPrice(double& total,double& price)
{
if (total==0)
{
cout<<"Enter the price of your first item."<<endl;
}
else
{
cout<<"Enter the price of your next item."<<
}
cin>>price;
}
double calcTotal(double& total, double& price)
{
total= total+price;
}
int askForItem(char& input)
{
cout<<"Do you have another item? (y/n)"<<endl;
cin>>input;
if (string input != "y") && (string input != "n")
{
cout<<"Please enter y or n"<<endl;
}
}
int main()
{
double total=0, price, change, paid;
int dollars, quarters, dimes, nickels, pennies;
string input="n";
while (input=="n")
{
getPrice(total,price);
calcTotal(total,price);
askForItem(input);
}
}