Need Assistance Solving Errors

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <iostream>
using namespace 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);
	}
}
Last edited on
closed account (48T7M4Gy)
if ((string input != "y") && (string input != "n"))
closed account (48T7M4Gy)
line 41 calls a function askForItem is written for char& and should be string.

ie askForItem (string input) or string& at line 22
Topic archived. No new replies allowed.