switch help

help please i only need this output when i choose a case for example i need this for case 1
cout<< "Press [A] to Add Employee" <<endl;
cout<< "Press [B] to Update Employee" <<endl;
cout<< "Press [C] to View All Employee"<<endl;
cout<< "Press [D] for Main Menu" <<endl;

but my code would output
cout<< "Press [A] to Add Employee" <<endl;
cout<< "Press [B] to Update Employee" <<endl;
cout<< "Press [C] to View All Employee"<<endl;
cout<< "Press [D] for Main Menu" <<endl;
cout<<"press [1] to manage employee " <<endl;
cout<<"press [2] to manage payslip" <<endl;
cout<<"press [3] for exit" <<endl;

how do i stop it from outputting the main choice


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
  #include <iostream>

using namespace std;

void manage_employee(){

    cout<< "Press [A] to Add Employee" <<endl;
    cout<< "Press [B] to Update Employee" <<endl;
    cout<< "Press [C] to View All Employee"<<endl;
    cout<< "Press [D] for Main Menu" <<endl;


}

void view_payslip(){

    cout<<"Press [A] to View Payslip" <<endl;
    cout<<"Press [B] to Create Payslip" << endl;
    cout<<"Press [C] to go to Main Menu" << endl;

}

void dot(){

    cout<< ". . . . . . . . . . . . . . ." <<endl;


}

int main(){


  int choice = 0;


    dot();
    cout << "PAYSLIP" << endl;
    dot();
    cout<< "Menu"<<endl;
  do{
    cout<<"press [1] to manage employee " <<endl;
    cout<<"press [2] to manage payslip" <<endl;
    cout<<"press [3] for exit" <<endl;
    dot();
    cin>>choice;

    switch(choice){
    case 1:
            cout<< "Manage Employee"<<endl;
            dot();
            manage_employee();
            break;

    case 2:
     cout<<"View Payslip" << endl;
            dot();
            view_payslip();
            break;
    case 3:
        cout<<"Good bye and Thank you" ;
        break;
    default:
        cout<<"invalid"<<endl;
    }

}
while (choice !=3);


return 0;
}
In case 1, after calling the manage employee function, the programme goes back to th3 beginning of the loop. If you handle some input in that case, you will get the desired effects.

Note, break doesnt pause the programme it justs ends the switch block.

Aceix.
thank you aceix really grateful fot this :D is it okey to expect your help in the future
Topic archived. No new replies allowed.