Error expected '(' before numeric constant &'(' before ';' token

Am recieve an error in line 244(second to last line) stating error expected '(' before numeric constant and error expected'(' before ';' token...

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
242
243
244
245
#include<iostream>
#include<cstdlib>
#include<conio.h>
#include<cmath>
   using namespace std;
int main ()
    {
int loopcount=0;
int total=0;
  int Total1=1;
char choice, choice1, choice2, choice3, choice4;
   int Answer,x,y;
   int NumbersAmount;
   int number;
 double x1,y1;
 double Answer1;
   double angle;
   system("COLOR 0c");
     cout<<"             Welcome to TwoSixEight Geeka Scientific Calculator\n";
   cout << "                      Coded by Jenell Joanne James\n\n";

  cout << " \n Enter the number of the function you'd like to calculate\n";
   do {
     cout<<"\t1 ~ Arithmetic Operations \n: ";
     cout<<"\t2 ~ Trigonometric Functions \n: ";
     cout<<"\t3 ~ Logarithmic Functions \n: ";
     cout<<"\t4 ~ Power Functions \n: ";
     cout<<"\t5 ~ Exit\n\n:";


     choice = getche();



     switch(choice)

     {
   case '1':

      {
   cout<< " \n\n Welcome to the Arithmetic Operations\n\n";
   cout<<" Enter the number of the operator you will like to select\n";
              cout<<"\t1 : Addition \n: ";
              cout<<"\t2 : subtraction \n: ";
              cout<<"\t3 : Multiplication \n: ";
              cout<<"\t4 : Division \n: ";
              choice1 = getche();
               switch(choice1)
                  {
                    case '1':
                             {
                            cout << "How many numbers are  you adding?\n";
                            cin >> NumbersAmount;

                             while (loopcount < NumbersAmount){
                               cout<<"Enter a number: ";
                               cin>>number;
                              total = total + number;
                                 loopcount = loopcount+1;

                            }
                             cout<<" Total is "<<total<<endl;


                              break;

                              }
                    case '2':
                          {
                       cout<<"Enter first number: ";
                      cin>>x;
                       cout<<"Enter an other number: ";
                       cin>>y;
                             Answer=x-y;
                       cout<<"The Answer is "<<Answer<<endl;

                        break;
                           }

                    case '3':
                             {
                               cout << "\nHow many numbers are you entering?\n";
                            cin >> NumbersAmount;

                             while (loopcount < NumbersAmount){
                               cout<<"Enter your number\n";
                               cin>>number;
                                Total1 = Total1 * number;
                                 loopcount = loopcount+1;

                             }
                              cout<<" Total is"<<Total1<<endl;

                              break;

                       }

                   case '4':
                             {
                         cout<<"Enter first number: ";
                          cin>>x;
                          cout<<"Enter an other number: ";
                           cin>>y;
                         if(x!=0)
                          {
                           Answer=x/y;
                             cout<<"The Answer is "<<Answer<<endl;


                          }
                                break;
                             }

                 }// end of inner switch
                 break;
           }// end of case 1 arithmetic operation

  case '2':
            {
       cout<<" Welcome to Trigonometric Functions\n\n";
             cout<<"1 ~ Sin function\n:";
             cout<<"2 ~ Cos function\n:";
             cout<<"3 ~ Tan function\n\n:";
             cout<<" Choose your function by typing in the associated number";
       choice2=getche();
       switch(choice2)
       {
       case '1':        {
        cout<<"Enter a angle: ";
        cin>>angle;

       Answer1=(sin(angle));
        cout<<"The answer is  "<<Answer1<<endl;

        break;
        }
       case '2':
        {
       cout<<" Enter a number: ";
       cin>>angle;
       Answer1=(cos(angle));
       cout<<"The answer is "<<Answer1<<endl;

         break;
        }
       case '3':
       {
       cout<< "Enter a number: ";
        cin>>angle;
          Answer1=(tan(angle));
         cout<<"The answer is "<<Answer1<<endl;

         break;
        }

      }// inner switch
       break;
            }//inner case 2 trignomatic
       case '3':
            {

       cout<<"\n1 ~ Natural log:";
       cout<<"\n2 ~Log with base 10:\n";
       choice3=getche();
       switch(choice3)
       {
      case '1':
        {
       cout<<" Enter a number: ";
        cin>>x1;
        Answer1=log(x1);
       cout<<"The answer is  "<<Answer1<<endl;

       break;
      }
      case '2':
        {
        cout<<"Enter a number: ";
        cin>>x1;
               Answer1= log10(x1);
        cout<<"The answer is "<<Answer1<<endl;

        break;
}
}// end of switch
          break;
}// end of case 3 logrithmic
       case '4':
{

       cout<<"\t ~  Press 1 for Power\n";
       cout<<"\t ~  Press 2 for Square root:\n";
       cout<<"\t ~  Press 3 for Square\n";
      cout<<"\t ~  Press 4 for Cube\n\n";
       cout<<"\tEnter your choice\n\n:";
       choice4=getche();
      switch(choice4)
{
       case '1':
{
        cout<<"      Enter a number: ";
         cin>>x1;
         cout<<"      Enter power: ";
         cin>>y1;         Answer1=pow(x1,y1);
         cout<<"The Answer is  "<<Answer1<<endl;

         break;
}
       case '2':
{
         cout<<"      Enter a number: ";
         cin>>x;
         Answer1=sqrt(x);
         cout<<"The Answer is "<<Answer1<<endl;

         break;

}
        case '3':
{
       cout<<"        Enter a number: ";
             cin>>x;
              Answer1= x*x;
              cout<<" The Answer is"<<Answer1<<endl;

  break;

}
  case '4':
{
  cout<<"             Enter a number: ";
  cin>>x;
  Answer1 =x*x*x;
 cout<<" The answer is"<<Answer1<<endl;
  break;
}

}//end switch
      break;
}//end of case power function    }//outer switch
}//do
}//

    return 0;
 }
Last edited on
Hi,

You don't have the while part of the do while loop :+)

Apart from that, your code is in desperate need of functions. There are so many nested switches; it becomes difficult to follow. I have mentioned this before, hopefully you will take this on board at some stage.

I am not a huge fan of do loops either: Did you know all 3 loops can be converted from one to another? IMO, it is always possible to use a while loop instead of a do loop, maybe at the cost of 1 more variable. Just because a do loop always executes at least once is not a sole reason for using it. A while loop can be written so it always executes at least once.

http://www.cplusplus.com/doc/tutorial/functions/


Good Luck!!
I am now irate because this is essentially a double post, please don't do this. It may be a different question but it is about the same code. Double posts are essentially a time waster, makes one wonder if they should bother answering at all.
closed account (48T7M4Gy)
Yep we've got another live one spoiling it for everybody.
No more music from me.


http://www.cplusplus.com/forum/general/180011/
Topic archived. No new replies allowed.