#include <iostream>
#include <iomanip>
{
void DispalyStoreItems ();

int ChoosingItems ();

double calculateChange ( int , int );

{
	int cost;

	DispalyStoreItems ();

	cost = ChoosingItems ();

	calculateChange ( int pay , int cost );

	system ("PAUSE");

	return 0;

void DispalyStoreItems ()
{
	std::cout <<"Code" << setw (10) << "Item" << setw (10) << "Price" << endl;

	std::cout << "------------------------" << endl;

	std::cout << setw (2) << "1" << setw (13) << "Bread" << setw (7) << "5" << endl;

	std::cout << endl;

	std::cout << setw (2)  << "2" << setw (11) << "Oil" << setw (9) << "8" << endl;

	std::cout << endl;

	std::cout << setw (2) << "3" << setw (13) << "Pizza" << setw (8) << "43" <<endl;

	std::cout << endl;

	std::cout << setw (2) << "4" << setw (14) << "Laptop" << setw (9) << "1199" << endl;

	std::cout << endl;

	std::cout << setw (2) << "5" << setw (16) << "Macaroni" << setw (5) << "20" << endl;

	std::cout << endl;

	std::cout << setw (2) << "6" << setw (12) << "Tuna" << setw (8) << "7" << endl;

	std::cout << endl;
}
int ChoosingItems ()
{
	int price;
	int item = 0;
	int cost = 0;
	int code = 0;
	int Bread = 0;
	int Oil = 0;
	int Pizza = 0;
	int Laptop = 0;
	int Macaroni = 0;
	int Tuna = 0;

	while ( true )
	{
		std::cout << "Enter the code of the Item you want to buy : ";

		cin >> code;

		std::cout << endl;

		if ( code == 0 )
			break;

		switch ( item )
		{
			case 1:
				Bread++;
				break;

			case 2:
				Oil++;
				break;

			case 3:
				Pizza++;
				break;

			case 4:
				Laptop++;
				break;

			case 5:
				Macaroni++;
				break;

			case 6:
				Tuna++;
				break;
		}

		if ( code == 1 )
		{
			price = 5;
		}
		else if ( code == 2 )
		{
			price = 8;
		}
		else if ( code == 3 )
		{
			price = 43;
		}
		else if ( code == 4 )
		{
			price = 1199;
		}
		else if ( code == 5 )
		{
			price = 20;
		}
		else if ( code == 6 )
		{
			price = 7;
		}
		else
		{
			price = 0;
		}

		cost += price;
	}

	if ( Bread != 0 )
		std::cout << "The User Buys " << item << "\n";
	if ( Oil != 0 )
		std::cout << "The User Buys " << item << "\n";
	if ( Pizza != 0 )
		std::cout << "The User Buys " << item << "\n";
	if ( Laptop != 0 )
		std::cout << "The User Buys " << item << "\n";
	if ( Macaroni != 0 )
		std::cout << "The User Buys " << item << "\n";
	if ( Tuna != 0 )
		std::cout << "The User Buys " << item << "\n";

	std::cout << "and Pays " << cost << "\n";

	return cost;
}
double calculateChange ( int pay, int cost )
{
	double units;
	double change;

	std::cout << "Enter the amount of the money you should pay : ";

	cin >> pay;

	std::cout << endl;

	change = pay - cost;

	if ( change >= 100)
	{
		change = ( change / 100 ) - ( units * 100 );

		std::cout << change << "Hundreds" << "\n";
	}
	if ( change >= 50 )
	{
		change = ( change / 50 ) - ( units * 50 );

		std::cout << change << "Fifties" << "\n ";
	}
	if ( change >= 10 )
	{
		change = ( change / 10 ) - ( units * 10 );

		std::cout << change << "Tens" << "\n";
	}
	if ( change >= 1 )
	{
		change = change - units;

		std::cout << change << "Ones" << "\n";
	}

	return change;
}
}

Please can you sort this out and repost it, Line 3 is saying unqualified-id before '{' token!!

Recommended Answers

All 4 Replies

i dont have a compiler on this pc but as this is a common error i usually find the reason is because you dont have a matching pair of brackets
ie. you have a {
but no }
double check each { and make sure everyone has a } to go with it.
Im confident you will find you are missing one }

Remove the brace at line 3. You're just declaring functions, and that shouldn't be included in anything. Put int main() in front of the brace at line 10 and put a closing brace after the return 0.

sorry it still dont work

sorry it still dont work

Do you mind telling us what 'doesn't work' ? Post new code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.