this message is coming up i cant get it off ERROR C2447

#include<iostream>
using namespace std;
int main();
{
	int item_purch, numb_of_purch, quit;
	char ('A' || 'a'), ('B' || 'b'), ('C' || 'c'), ('D' || 'd');
	double mugs, teeshirts, pens, tot_mon, curr_cash, mon_spent;
	

	cout << "Welcome to the Southern Illinois Bookstore."; << endl;
	cout << "For a limited time merchandice with a cougar logo is being sold"; << endl;
	cout << "at a reduced rate."; << endl;
	cout << "What do you want to purchase today?\n ";
	symb1 = ('A' || 'a'), symb2 = ('B' || 'b'), symb3 = ('C' || 'c'), symb4 = ('D' || 'd');
	
	end of main();
}

Recommended Answers

All 4 Replies

Welcome to the board!

There is a number of problems with your code, but since I haven't memorized the meaning of error # 2447 I can't say which one it is.

1) The first thing I would do is remove the semicolon at the end of this line:

int main();

2) Then I would use your reference of choice to review how to declare variables as this line:

char ('A' || 'a'), ('B' || 'b'), ('C' || 'c'), ('D' || 'd');

is inappropriate. What are you trying to do with that line?

3) Then, remove the semicolons before each << endl;

4) Remove this line for now:

symb1 = ('A' || 'a'), symb2 = ('B' || 'b'), symb3 = ('C' || 'c'), symb4 = ('D' || 'd');

5) Replace this line:

end of main();

with this:

return 0;

6) As regards posting to the board please don't resurrect long dead threads. If you have a question and you can't figure it out by looking at past threads, start a new thread asking your question and when you do post code, or something else that has embedded line formatting, please do use code tags. The use of code tags is explained numerous placing on the board.

and this what is a better way too write this without getting an error

if ((symb1 != 'A', 'a') || (symb2 != 'B', 'b') || (symb3 != 'C', 'c') || (symb4 != 'D', 'd'));; << endl;
            
           {          
               cout << "Please enter an corresponding letter." << endl;
            }

and this what is a better way too write this without getting an error

while  ((symb1 != 'A', 'a') || (symb2 != 'B', 'b') || (symb3 != 'C', 'c') || (symb4 != 'D', 'd'));; >> endl;
            
             {
               cout << "Wrong" << endl; 
                    << "Enter one of the four letters.\n" ;
               cin >> symb1 >> symb2 >> symb3 >> symb4;
			 }
	else 
		cout << "You have chosen" << symb << endl;

and this is my program and i cant run it without errors, its 4 school so could u give me advise so i will know in the future

#include<iostream>
#include<string>
using namespace std;
int main()
{
   char symb1, symb2, symb3, symb4;
   int item_purch, numb_item_purch, quit;
   double mug, tee_shirt, pen,tot_mon, curr_cash, mon_spent;
  
   cout << "So what do you want to purchase today?\n";
   symb1=('A','a'); 
   symb2=('B','b');
   symb3=('C','c'); 
   symb4=('D','d');
   cout << symb1 << " Mug" << mug << endl;
   cout << symb2 << " Tee Shirt " << tee_shirt << endl;
   cout << symb3 << " Pen " << pen << endl;
   cout << symb4 << " Quit " << quit << endl;
   mug = 2.50;
   tee_shirt = 9.50;
   pen = .75;
    if ((symb1 != 'A', 'a') || (symb2 != 'B', 'b') || (symb3 != 'C', 'c') || (symb4 != 'D', 'd'));; << endl;
            
           {          
               cout << "Please enter an corresponding letter." << endl;
            }
	else 
		cout << "You have chosen" << symb << endl;
   
  cin >> symb1;
  cin >> symb2;
  cin >> symb3;
  cin >> symb4;
  cout << "You have a total of 30 dollars.\n";
  cin >> tot_mon;
  tot_mon = 30;
   cout << "Please pick a letter that corresponds with the merchandice of your choosing.\n";\
  
       while  ((symb1 != 'A', 'a') || (symb2 != 'B', 'b') || (symb3 != 'C', 'c') || (symb4 != 'D', 'd'));; >> endl;
            
             {
               cout << "Wrong" << endl; 
                    << "Enter one of the four letters.\n" ;
               cin >> symb1 >> symb2 >> symb3 >> symb4;
			 }
                }
  
   return 0;
}

this is what im tryin to do

You are to write a program that:
1. Shows the user how much money they have and lists the items they can choose to buy, plus an option to quit.
2. Accepts the user’s choice of which item to buy. If the user chose to quit, then go to step #6.
3. If the user can afford to buy one or more of the items they chose to buy, ask them how many they want. Once they have chosen how many they want, subtract the amount it costs to buy those items from their current money amount. Make sure to keep track of how many of each item they buy.
4. Go back to step #1 unless the user does not have enough money to buy anything else. If they don’t have enough money, go to step #5.
5. Because the user ran out of money, tell them that they can’t afford any more stuff.
6. Show the user a final report that tells them how much money they have left over and how many of each item they bought. Then quit the program.

compound conditionals are always a little bit tricky, but the first thing is you should only compare one variable on the left hand side of an operator with one variable on the right hand side of the operator. So it should be:

if((symb1 != 'A' || symb1 != 'a') || (symb2 != 'B' || symb2 != 'b')) 
  display error message 

etc. The logic you are trying to get looks like you want "if none of the these symbols have the correct value then display an error message." However, it may be easier logic to do something a little different, like maybe "if any of these are true, then proceed, otherwise display error message". That logic would be something like:

if(symb1 == 'A' || symb1 == 'a' || symb2 == 'B' || symb2 == 'b'....etc.

I happen to think something along the follow might be better:

if(symb1 == 'A' || symb1 == 'a')
  do something
else if (symb2 == 'B' || symb2 == 'b')
  do something else
.
.
.
else 
  display error message

But, based on the description of the problem as you have posted it, I think the best approach would be to use a switch statement; if you know what a switch statement is, of course. If you don't know what a switch statement is, then you could structure the program flow to act line one. maybe something like this:

display menu
get users choice into a variable called choice
if choice == 'A' || choice == 'a'
  check if funds available to pay for at least 1 A
  if funds available ask how many
  check if funds available for number requested
  keep track of how many A's have been requested.
else if choice == 'B' || choice == 'b'
.
.
.
else
  that is not a valid option.
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.