I need help. Error c2447

Hi I wrote this simple program to calculate tax and what not, been trying to figure out what is wrong with it. Fixed all of the errors except this one. Been trying to figure it out for hours. Any help would be greatly appreciated.

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;

const double STATE_TAX = 0.04;
const double COUNTY_TAX = 0.02;
 
int main();
		
{

     float month,
        year,
        total,
        sales,
        countytax,
        statetax,
        totaltax;

    cout << "Please enter the month: ";
    cin >> month;
    cout << "Please enter the year: ";
    cin >> year;
    cout << "Please enter total amount recieved at cash register: "; 
    cin >> total;

        sales = total / (1 + (COUNTY_TAX + STATE_TAX));
        countytax = total * COUNTY_TAX;
        statetax = total * STATE_TAX;
        totaltax = countytax + statetax;


    cout << fixed << setprecision(2);
    cout << "Month: " << month << " " << year << endl;
    cout << "------------------------" endl;
    cout << "Total Collected: " << setw(8) << "$" << total << endl;
    cout << "Sales: " >> setw (8) << "$" << sales << endl;
    cout << "County Sales Tax: " << setw(8) << countytax << endl;
    cout << "State Sales Tax: " << setw(8) << statetax << endl;
    cout << "Total Sales Tax: " << setw(8) << totaltax << endl;

        return 0;

                }
I have fixed your problem look nicely what mistake you have done.At first include header file
#include<iomanip>
This header file is needed for setw() and setprecision() manupulator.
In line 7 your code is
int main();
don't use semicolon after main. your code must look
int main()
In line 34
cout << "------------------------" endl;
you have missed insertion operator (<<).your code must look
cout << "------------------------" <<endl;
In line 36
cout << "Sales: " >> setw (8) << "$" << sales << endl;
you have used ">>" operator instead of "<<" operator and code must be like this.
cout << "Sales: " << setw (8) << "$" << sales << endl;
I think I have fixe all the error.If anything occur you can ask any question or send email.You can also visit my blog www.codeincodeblock.blogspot.com for programming tips and trick.
Knew it would be something simple. Thanks alot, made all those changes and now it compiles fine. But now im having trouble when running it. When i run it now it starts, asks for the month, then the program just closes. Here is my code now.

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
44
45
46
47
#include <iostream>
#include <iomanip>
using namespace std;

const float STATE_TAX = 0.04;
const float COUNTY_TAX = 0.02;
 
int main()
		
{
     
     float 
     month,
     year,
     total,
     sales,
     countytax,
     statetax,
     totaltax;
        
  cout << "Please enter the month: ";
    cin >> month;  
    
    cout << "Please enter the year: ";
    cin >> year;
    
    cout << "Please enter total amount recieved at cash register: "; 
    cin >> total;

        sales = total / (1 + (COUNTY_TAX + STATE_TAX));
        countytax = total * COUNTY_TAX;
        statetax = total * STATE_TAX;
        totaltax = countytax + statetax;


    cout << fixed << setprecision(2);
    cout << "Month: " << month << " " << year << endl;
    cout << "------------------------" << endl;
    cout << "Total Collected: " << setw(8) << "$" << total << endl;
    cout << "Sales: " << setw (8) << "$" << sales << endl;
    cout << "County Sales Tax: " << setw(8) << countytax << endl;
    cout << "State Sales Tax: " << setw(8) << statetax << endl;
    cout << "Total Sales Tax: " << setw(8) << totaltax << endl;

        return 0;

                }


Any ideas what the problem could be?
What are you using as input?

-Albatross
I see where this is going, i put the data type as float when i am entering something like "May" for month! What data type should i use?
I'm guessing you would use a string.
Unless you're using a format like 7/2/10, I would suggest using int.
Last edited on
Thank you guys so much!! Works fine now, just need to fix up a bit of the formatting. You guys are awesome!!!
No problem occur when I compile it code::blocks your code is error free.
Topic archived. No new replies allowed.