This is not compiling in Xcode, very confused

Xcode gives me errors, and when I fix what it wants me to fix, I get more errors. Currently the errors given are:
'unknown type name " '-line 2
'expected ';' after top level declarator' -line 5
'unknown type name 'int' " -line 12
'expected function body after function declarator' - line 13

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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//AcmePayroll.cpp
  //Te Mat
 // June 29, 2014//Project 1
  //[Uses information entered by user to calculate payroll]#include <iostream>#include <iomanip>

using namespace std;

int main()// function main begins program execution
{
    int paycode,
        TotalHours,
        sales;
    double pay1,
           pay2,
           pay3,
           pay4,
           TotalPay,
           HourlyPay,
           SalesComm,
           WeeklySalary,
           WeeklyPay,
           PayPerWidget,
           WidgetsSold,
           GrossWeeklySales;

    cout << "Enter pay code ([Q]uit):";
    cin >> paycode;
    
    cout << fixed << showpoint << setprecision(2);
    
    switch (paycode)
    {
        case 1:
            cout << "Manager selected." << endl;
            cout << "Enter weekly salary: ";
            cin >> WeeklySalary;
            cout << endl;
            
            pay1 = WeeklySalary;
            cout << "Managers pay is $" << pay1;
            cout << endl;
            break;
            
        case 2:
            cout << "Hourly Worker selected." << endl;
            cout << "Enter the hourly pay:";
            cin >> HourlyPay;
            cout << endl;
            
            cout << "Enter the total hours worked:";
            cin >> TotalHours;
            
            if (TotalHours <= 40)
                pay2 = HourlyPay * TotalHours;
            else
                pay2 = (40 * HourlyPay) + (TotalHours - 40) * (HourlyPay * 1.5)
            
                cout << endl;
            cout << "Hourly Worker's pay is $"; << pay2;
            cout << endl;
            break;
            
        case 3:
            cout << "Commission Worker selected." << endl;
            cout << "Enter weekly salary:";
            cin >> WeeklyPay;
            cout << endl;
            
            cout << "Enter commission (%): ";
            cin >> SalesComm;
            cout << endl;
            
            cout << "Enter gross weekly sales:";
            cin >> GrossWeeklySales;
            cout << endl;
            
            pay3 = (SalesComm / 100) * GrossWeeklySales + WeeklyPay;
            cout << " Commission Worker's pay is $" << pay3;
            cout << endl;
            break;
            
        case 4:
            cout << "Widget Worker selected." << endl;
            cout << "Enter pay per widget:";
            cin >> PayPerWidget;
            cout << endl;
            
            cout << "Enter number of widgets: ";
            cin >> WidgetsSold;
            cout << endl;
            
            pay4 = PayPerWidget * WidgetsSold;
            cout << "Widget Worker's pay is $" << pay4;
            cout << endl;
            break;
            
            TotalPay = pay1 + pay2 + pay3 + pay4;
            char usersPression = ' ' ;
            
            do
            {
                cout << " Total pay is $" << TotalPay;
            }while(usersPression != 'Q' && usersPression != 'q');
       
            }
return 0;
            
            
    }
You already had a thread open, you should have just posted in that one again

"Unknown type name (little picture of a box)

Is it referring to the weird symbols you have at the beginning of your code? What is this ? Get rid of those if that's in your actual code.
Last edited on
I don't know which symbols you're referring to. The beginning of the code is supposed to just be comments after the // symbols because my teacher requires it.
It's not the comments, but some strange symbol that you have scattered throughout the beginning of your code. It is in front of both of your include statements, for example- not the #, but left of the #.
You don't see weird symbols in your original post? It might be showing up as something else on your computer, depending on language character packages or something.
http://i1093.photobucket.com/albums/i434/GanadoFO/symbols.png
It might just be a copy-paste issue, but it sounds like those symbols you have there are indeed affecting your code.

You're also missing a semi-colon
1
2
            else
                pay2 = (40 * HourlyPay) + (TotalHours - 40) * (HourlyPay * 1.5) //here 

It is best to be able to spot things like this using the errors a compiler will yell out, it can save a lot of time.
Last edited on
No I don' see them. That is so strange, I don't know how to remove symbols if I can't see them in my code. Hmm. I'm sure you're right, that must be what's causing at least some of the issue. I appreciate your help!
int sales; is not used anywhere in your code.

cout << "Hourly Worker's pay is $"; << pay2; has a semi-colon somewhere it shouldn't.

Which editor/IDE are you using? What ever you're using it's not using Unicode as it's default encoding. Are you using custom system fonts?
Last edited on
closed account (z05DSL3A)
tem14b,

I have removed the stray characters from your original code, copy this and replace the code in Xcode.

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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//AcmePayroll.cpp
  //Te Mat
 // June 29, 2014
  //Project 1
  //[Uses information entered by user to calculate payroll]

#include <iostream>
#include <iomanip>

using namespace std;

int main()// function main begins program execution
{
    int paycode,
        TotalHours,
        sales;
    double pay1,
           pay2,
           pay3,
           pay4,
           TotalPay,
           HourlyPay,
           SalesComm,
           WeeklySalary,
           WeeklyPay,
           PayPerWidget,
           WidgetsSold,
           GrossWeeklySales;

    cout << "Enter pay code ([Q]uit):";
    cin >> paycode;
    
    cout << fixed << showpoint << setprecision(2);
    
    switch (paycode)
    {
        case 1:
            cout << "Manager selected." << endl;
            cout << "Enter weekly salary: ";
            cin >> WeeklySalary;
            cout << endl;
            
            pay1 = WeeklySalary;
            cout << "Managers pay is $" << pay1;
            cout << endl;
            break;
            
        case 2:
            cout << "Hourly Worker selected." << endl;
            cout << "Enter the hourly pay:";
            cin >> HourlyPay;
            cout << endl;
            
            cout << "Enter the total hours worked:";
            cin >> TotalHours;
            
            if (TotalHours <= 40)
                pay2 = HourlyPay * TotalHours;
            else
                pay2 = (40 * HourlyPay) + (TotalHours - 40) * (HourlyPay * 1.5);
            
            cout << endl;
            cout << "Hourly Worker's pay is $" << pay2;
            cout << endl;
            break;
            
        case 3:
            cout << "Commission Worker selected." << endl;
            cout << "Enter weekly salary:";
            cin >> WeeklyPay;
            cout << endl;
            
            cout << "Enter commission (%): ";
            cin >> SalesComm;
            cout << endl;
            
            cout << "Enter gross weekly sales:";
            cin >> GrossWeeklySales;
            cout << endl;
            
            pay3 = (SalesComm / 100) * GrossWeeklySales + WeeklyPay;
            cout << " Commission Worker's pay is $" << pay3;
            cout << endl;
            break;
            
        case 4:
            cout << "Widget Worker selected." << endl;
            cout << "Enter pay per widget:";
            cin >> PayPerWidget;
            cout << endl;
            
            cout << "Enter number of widgets: ";
            cin >> WidgetsSold;
            cout << endl;
            
            pay4 = PayPerWidget * WidgetsSold;
            cout << "Widget Worker's pay is $" << pay4;
            cout << endl;
            break;
            
            TotalPay = pay1 + pay2 + pay3 + pay4;
            char usersPression = ' ' ;
            
            do
            {
                cout << " Total pay is $" << TotalPay;
            }while(usersPression != 'Q' && usersPression != 'q');
       
            }
return 0;
            
            
    }
GreyWolf, you forgot to remove that unreferenced variable! I'm not sure why that's there to be honest. ;D

closed account (z05DSL3A)
Sausage, I didn't forget to remove anything, I only got it to a state where it would compile for the OP so he can carry on with his work.
GreyWolf

Oops, I didn't realise you wasn't the OP. I thought the OP reposted an updated version. I didn't check names.
Wow I sounded very patronising then, I apologise, I mean't to remind the OP.
Last edited on
@tem14b
Don't double post ( http://www.cplusplus.com/forum/beginner/136970/ ). Like Ganado pointed out, you should have kept to that thread. tributo had answered, though in rude way (ie being a smarta**), the ';' error and if you got more errors (which this thread seems to show) you should have posted that in that thread. Every compilation error for the same program doesn't need its own thread to fix.
Last edited on
Topic archived. No new replies allowed.