Im new to c++ and switch case menu

I keep getting this error
In function 'int main()':|
|93|error: expected 'while' before '}' token|
|93|error: expected '(' before '}' token|
|93|error: expected primary-expression before '}' token|
|93|error: expected ')' before '}' token|
|93|error: expected ';' before '}' token|
||=== Build failed: 5 error(s), 2 warning(s) (0 minute(s), 0 second(s)) ===|


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
#include <iostream>
#include "INDITASK2.h"
using namespace std;

int main()
{
    list employeeList;
    int eid,weight,x,y;
    double bmi,height,Bmi1,Bmi2;
    address P;
    int input;
    do{

        cout<<"\n\nPROGRAM"<<endl;
        cout<<"1.Create Empty Employee List"<<endl;
        cout<<"2.Input Employee List"<<endl;
        cout<<"3.Input New Employee at the top of the list"<<endl;
        cout<<"4.Input New Employee at the bottom of the list"<<endl;
        cout<<"5.Delete The First Employee at the List"<<endl;
        cout<<"6.Delete The Last Employee at the list"<<endl;
        cout<<"7.Show all healthy employee"<<endl;
        cout<<"8.Sort the list based on bmi"<<endl;
        cout<<"9.Find Employee ID and show Their Health Status"<<endl;
        cout<<"10.Show Employee based on BMI Range"<<endl;
        cout<<"11.Search Employee ID"<<endl;
        cout<<"0.EXIT PROGRAM"<<endl;
        cout<<"ENTER YOUR CHOICE : ";
        cin>>input;

        switch (input){
            case '1' :
                createList(employeeList);
                cout<<"List has been created"<<endl;
                break;
            case '2' :
                cout<<"Input 0 to end inputting data"<<endl;
                insertZero(employeeList);
                break;
            case '3' :
                cout<<"INPUT DATA : "<<endl;
                cout<<"Employee ID : ";
                cin>>eid;
                cout<<"Employee HEIGHT (In Meter) : ";
                cin>>height;
                cout<<"Employee WEIGHT (In Kilogram) : ";
                cin>>weight;
                InsertFirst(employeeList,alokasi(eid,weight,height,bmi));
                break;
            case '4' :
                cout<<"INPUT DATA : "<<endl;
                cout<<"Employee ID : ";
                cin>>eid;
                cout<<"Employee HEIGHT (In Meter) : ";
                cin>>height;
                cout<<"Employee WEIGHT (In Kilogram) : ";
                cin>>weight;
                InsertLast(employeeList,alokasi(eid,weight,height,bmi));
                break;
            case '5' :
                deleteFirst(employeeList,P);
                cout<<"Data has been deleted"<<endl;
                break;
            case '6' :
                deleteLast(employeeList,P);
                cout<<"Data has been deleted"<<endl;
                break;
            case '7' :
                printHealthy(employeeList);
                break;
            case '8' :
                sorting(employeeList);
                break;
            case '9' :
                cout<<"Find ID : "<<endl;
                cin>>x;
                findID(employeeList,x);
                break;
            case '10' :
                cout<<"FIND EMPLOYEE BASED ON BMI RANGE"<<endl;
                cin>>Bmi1;
                cin>>Bmi2;
                findRange(employeeList,Bmi1,Bmi2);
                break;
            case '11' :
                cout<<"FIND ID "<<endl;
                cin>>y;
                findID2(employeeList,y);
                break;
            case '0' :
                return 0;
        }
    }
}
Your do needs a while at the end of it.

You should not be surrounding your case numbers in single quotes. That will check to see if they equal a character value instead of an integer.

Since you did not post the source code of the INDITASK2.h, I do not know if there are any errors in there.
Topic archived. No new replies allowed.