Hi, I am writing a program and ive recive these two errors all of a sudden saying Error expected at the end of input and error expected primary expression at at the end of input... Can anyone figure out the error?
Line error is on the last line
#include<iostream>
#include<cstdlib>
#include<conio.h>
#include<cmath>
usingnamespace 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
}
while (choice!='5');
}
return 0 ;
}
I just had a quick look at your code using the shell and also what you presneted here.
You have a series of stuff ups with braces etc and you will need to:
1. Properly present your code professionally especially using proper indentation.
2. Line 241 is rubbish that does nothing. Get rid of it.
3. Make sure all braces balance.
You're in for some fairly easy editing and debugging if you do that and if you understand the code you're using.