Apr 20, 2013 at 6:39pm UTC
the errors im getting are:
In function 'int main()':
error: expected 'while' before '}' token
error: expected '(' before '}' token
error: expected primary-expression before '}' token
error: expected ')' before '}' token
error: expected ';' before '}' token
these errors are all occurring on line 132.
as you may also notice it is not 100% complete that is because i am building it up as i go and have been writing it for a couple of evenings.
any help would be highly appreciated
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
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
{
double firstNumber = 0.0;
double secondNumber = 0.0;
char operation =' ' ;
return 0;
do
{
cout << "welcome to Calculator++." << endl;
cout << "Select Operation" << endl;
cout << "1. Standard calculator operations" << endl;
cout << "2. Trigonometry" << endl;
cout << "3. Statistics" << endl;
int M;
cin >> M;
if ( M == 1 ){
cout << "1. Addition" << endl;
cout << "2. Subtraction" << endl;
cout << "3. Multiplication" << endl;
cout << "4. Division" << endl;
cout << "5. Square a number" << endl;
cout << "6. Cube a number" << endl;
cout << "7. Exponent's ( X^n)" << endl;
cout << "8. Squareroot" << endl;
cout << "9. Cuberoot" << endl;
cout << "10. Log [log10(x)]" << endl;
cout << "11. Finding the length of a hypotenuse" << endl;
{
cout << "Enter first Number" << endl;
cin>>firstNumber;
cout << "Enter operation number (1 to 8)" << endl;
cin>>operation;
cout << "Enter second Number (do not enter number for operation 5, 6, 8, 9 & 10)" << endl;
cin>>secondNumber;
int Op;
cin >> Op;
if ( Op == 1){
cout << "the answer is..." <<firstNumber<<"+" <<secondNumber<<"=" <<(firstNumber+secondNumber) << endl;
break ;
}
if ( Op == 2){
cout << "the answer is..." <<firstNumber<<"-" <<secondNumber<<"=" <<(firstNumber-secondNumber) << endl;
break ;
}
if ( Op == 3){
cout << "the answer is..." <<firstNumber<<"*" <<secondNumber<<"=" <<(firstNumber*secondNumber) << endl;
break ;
}
if ( Op == 4){
cout << "the answer is..." <<firstNumber<<"/" <<secondNumber<<"=" <<(firstNumber/secondNumber) << endl;
break ;
}
if ( Op == 5){
cout << "the answer is..." <<firstNumber<<"*" <<firstNumber<<"=" <<(firstNumber*firstNumber) << endl;
break ;
}
if ( Op == 6){
cout << "the answer is..." <<firstNumber<<"*" <<firstNumber<<"*" <<firstNumber<<"=" <<(firstNumber*firstNumber*firstNumber) << endl;
break ;
}
if ( Op == 7){
cout << "the answer is..." <<std::pow(firstNumber, secondNumber) << endl;
break ;
}
if ( Op == 8){
cout << "the answer is..." <<std::sqrt(firstNumber) << endl;
break ;
}
if ( Op == 9){
cout << "the answer is..." <<std::cbrt(firstNumber) << endl;
break ;
}
if ( Op == 10){
cout << "the answer is..." <<std::log10(firstNumber) << endl;
break ;
}
if ( Op == 11){
cout << "the answer is..." <<std::hypot(firstNumber,secondNumber) << endl;
break ;
}
return 0;
}
if ( M == 2 ){
cout << "1. Cos(angle)" << endl;
cout << "2. Sin(angle)" << endl;
cout << "3. Tan(angle)" << endl;
cout << "4. Sine (find an angle)" << endl;
cout << "5. Sine (find a length)" << endl;
cout << "6. Cosine (find an angle)" << endl;
cout << "7. Cosine (find a length) " << endl;
cout << "8. Degrees to Raidians" << endl;
cout << "9. Radians to Degrees" << endl;
cout << "10. Arc Length" << endl;
cout << "11. Area of a Sector" << endl;
cout << "12. Area of a segment in a circle" << endl;
return 0;
}
if ( M == 3 ){
cout << "1. " << endl;
cout << "2. " << endl;
cout << "3. " << endl;
cout << "4. " << endl;
cout << "5. " << endl;
cout << "6. " << endl;
cout << "7. " << endl;
return 0;
}
}
}
}
}
Last edited on Apr 20, 2013 at 6:41pm UTC
Apr 20, 2013 at 6:47pm UTC
The problem clearly lies in all those messed up brackets/braces (whatever they're called), but it's impossible to debug this, because the indentation sucks. So first fix that, then the problem will be obvious, I think.
Apr 20, 2013 at 6:52pm UTC
I agree the indentation sucks. The problem though is that you are missing the while in your do-while loop. It should be after the curly bracket on line 131. So something like
} while (true );
That would be the missing while while
The missing '(' (
The missing expression true
The missing ')' )
And the missing ';' ;
Apr 20, 2013 at 7:00pm UTC
have not included the last two which are for the 'do' and the 'int main()'
Last edited on Apr 20, 2013 at 7:00pm UTC