Menu help

can you help me get this menu to work!
here's it is
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
//Library includes Here!!!
#include <iostream>
using namespace std;

//Global Constants Here!!!

//Function Prototypes Here!!!
void Menu();
int getN();
void def(int);
void problem1();
void problem2();
void problem3();
void problem4();
void problem5();
void problem6();

//Begin Execution Here!!!
int main(int argv,char *argc[]){
    int inN;
    do{
        Menu();
        inN=getN();
        switch(inN){
        case 1:    problem1(/*
                  david ballantyne
                  10/15/13
                  purpose: ask for the number of lines the
                           user wants to output
                */
                
                //libraries
                #include <iostream>
                using namespace std;
                
                //global constants
                
                //no functioning prototype
                
                int main(){
                    //Define variables
                    int n,i,k;
                    char ans;
                do{
                    // Have user input n
                    cout << "Enter number of rows: "<<endl;
                    cin >> n;
                
                    // Complete for loop
                    for (i = 1; i <= n + 1; i++){
                    for (k = 1; k < i; k++){
                    if (k<i-1) cout << ' '; 
                    else cout << k <<endl;
                    }
                    }
                    cout<<"Enter Y or y if you would like to rerun the program"<<endl;
                    cin>>ans;
                    }
                    while(ans=='Y'||ans=='y');
                
                    system("PAUSE");
                    return EXIT_SUCCESS;
                });break;
        case 2:    problem2();break;
        case 3:    problem3();break;
        case 4:    problem4(
                        /*
                          David Ballantyne
                          10/16/13
                          Purpose: determine pay 
                        */
                        
                        //Libraries
                        #include <cstdlib>
                        #include <iostream>
                        using namespace std;
                        
                        //Global Constants
                        
                        //Functioning Prototypes
                        
                        int main(int argc, char *argv[]){
                            //char ans;// for the do-while loop
                            float pay, hours, subttl, ttl, otp, otp2; 
                            char ans;
                        do{
                            //Prompt User
                            cout<<"Enter hours worked "<<endl;
                            cin>>hours;
                            cout<<"Enter pay rate $"<<endl;
                            cin>>pay;
                            //overtime pay for hours worked over 40
                            if (hours >= 40.0){
                            otp=(hours-40)*2*pay;
                            otp2=((hours-20)-(hours-40))*1.5*pay;
                            ttl= otp+otp2+(20*pay);
                             }    
                            //over time pay for hours worked over 20
                            else if( hours >= 20.0){
                            otp=((hours-20)*1.5)*pay;
                            subttl= (hours*pay)-((hours-20)*pay);
                            ttl= subttl+otp;
                             }    
                            //pay worked for hours less than 20
                            else if(hours <= 20.0){
                            ttl=pay*hours;
                             }    
                            
                             cout<<"Your total pay is $"<<ttl<<endl;
                             cout<<"Run this again? Enter Y/y for yes, anything else to exit.\n";
                             cin>>ans;
                           }
                             while(ans=='Y'||ans=='y');
                             
                            system("PAUSE");
                            return EXIT_SUCCESS;
                        }
);break;
        case 5:    problem5(/*
                  David Ballantyne
                  10/17/13
                  purpose: determin monthly bill for ISP
                */
                
                //Libraries
                #include <cstdlib>
                #include <iostream>
                using namespace std;
                
                //Global Constants
                
                //Functioning Prototypes
                
                //Execution Begins Here
                int main(int argc, char *argv[]){
                    
                    //Declare Variables
                    float rate, hours;
                    char option, ans;
                    
                    //promt user
                do{
                    cout<<"Which ISP package would you like to choose from?"<<endl;
                    cout<<"Enter A, B, or C: "<<endl;
                    cin>>option;
                    
                    cout<<"How many hours have you used so far? "<<endl;
                    cin>>hours;
                
                             
                    switch(option)
                    {
                                  case'A||a': 
                                  if (hours<=11){
                                     rate=29.95;
                                     }
                                     else if (hours>11 && hours <= 22){
                                     rate=29.95 + ((hours-11)*2.5f);
                                     }
                                     else if (hours>22){
                                     rate=29.95 +(11*2.5)+((hours-22)*5.0);
                                     }    
                                     
                                  break;
                                  case'B||b':
                                  if (hours<=22){
                                     rate=34.95;
                                     }
                                     else if (hours>22 && hours <= 33){
                                     rate=34.95 + ((hours-22)*1.25f);
                                     }
                                     else if (hours>33){
                                     rate=34.95 +(11*1.25f)+((hours-33)*2.5f);
                                     }    
                                  
                                  break;
                                  case'C||c':
                                  rate=39.95;                  
                                  break;
                                  }
                    cout<<"Your Monthly Rate comes out to $"<<rate<<endl;
                    
                    cout<<"Run this again? Enter Y/y for yes, anything else to exit."<<endl;
                    cin>>ans;
                }
                     while(ans=='Y'||ans=='y');
                    
                    system("PAUSE");
                    return EXIT_SUCCESS;
                }
);break;
        case 6:    problem6();break;
        default:   def(inN);}
    }while(inN>=1&&inN<=6);
    return 0;//If midterm not perfect, return something other than 1
}

void Menu(){
    cout<<"Menu for the Midterm"<<endl;
    cout<<"Type 1 for problem 1"<<endl;
    cout<<"Type 2 for problem 2"<<endl;
    cout<<"Type 3 for problem 3"<<endl;
    cout<<"Type 4 for problem 4"<<endl;
    cout<<"Type 5 for problem 5"<<endl;
    cout<<"Type 6 for problem 6"<<endl;
    cout<<"Type anything else to exit \n"<<endl;
}

int getN(){
        int inN;
        cin>>inN;
        return inN;
}

void problem1(){
        cout<<"In problem # 1"<<endl<<endl;
}

void problem2(){
        cout<<"In problem # 2"<<endl<<endl;
}

void problem3(){
        cout<<"In problem # 3"<<endl<<endl;
}

void problem4(){
        cout<<"In problem # 4"<<endl<<endl;
}

void problem5(){
        cout<<"In problem # 5"<<endl<<endl;
}

void problem6(){
        cout<<"In problem # 6"<<endl<<endl;
}

void def(int inN){
        cout<<"You typed "<<inN<<" to exit the program"<<endl;
}

closed account (o3hC5Di1)
Hi there,

Especially when posting a large section of code like this, please be a little bit more specific about the problems you encounter.

Does the program compile? if not, which errors do you get? Is it behaving differently from what you expect? if so, what do you expect and what does it do?

That will help us to help you more efficiently.

Thanks,
NwN
Topic archived. No new replies allowed.