the error is on line ,12, how do i fix them...they are expected unqualified-id before '}' token ,and expected `,' or `;' before '}' token and, expected declaration before '}' token
#include <iostream>
usingnamespace std;
class setup{
public:
void title(){
cout << "hello!!!, IM A CALCULATOR... lets get started" << endl << endl;
}
};
int main()
{
system("TITLE calculator");
system("color 2");
double a;
double b;
char cchar;
char cagain;
do{
system("CLS");
cout << "please enter the first number you want to use" << endl;
cin >> a;
cout << "please enter the number you would like to use" << endl;
cin >> cchar;
cout << "please enter the second number you would like to use" << endl;
cin >> b;
switch (cchar){
case'+':
cout << "the answer is: " << a << " + " << b << " = "
<< (a + b) << endl;
break;
case'-':
cout << "the answer is: " << a << " - " << b << " = "
<< (a - b) << endl;
break;
case'*':
cout << "the answer is: " << a << " * " << b << " = "
<< (a * b) << endl;
break;
case'/':
cout << "the answer is: " << a << " / " << b << " = "
<< (a / b) << endl;
break;
default:
cout << "you cant use that operation";
break;
}
cout << "would you like to start again (y or n)";
cin >> cagain;
}while (cagain == 'y' || cagain == 'Y');
system("pause");
return 0;
}
You seem to misunderstand the point of classes. But the technical reason is because you never create a setup object and call the title() method anywhere.
#include <iostream>
usingnamespace std;
class setup{
public:
void title(){
cout << "hello!!!, IM A CALCULATOR... lets get started" << endl << endl;
}
};
int main()
{
setup setapp1;
setup.title();
system("TITLE calculator");
system("color 2");
double a;
double b;
char cchar;
char cagain;
do{
system("CLS");
cout << "please enter the first number you want to use" << endl;
cin >> a;
cout << "please enter the number you would like to use" << endl;
cin >> cchar;
cout << "please enter the second number you would like to use" << endl;
cin >> b;
switch (cchar){
case'+':
cout << "the answer is: " << a << " + " << b << " = "
<< (a + b) << endl;
break;
case'-':
cout << "the answer is: " << a << " - " << b << " = "
<< (a - b) << endl;
break;
case'*':
cout << "the answer is: " << a << " * " << b << " = "
<< (a * b) << endl;
break;
case'/':
cout << "the answer is: " << a << " / " << b << " = "
<< (a / b) << endl;
break;
default:
cout << "you cant use that operation";
break;
}
cout << "would you like to start again (y or n)";
cin >> cagain;
}while (cagain == 'y' || cagain == 'Y');
system("pause");
return 0;
}
#include <iostream>
usingnamespace std;
class setup{
public:
void title(){
cout << "hello!!!, IM A CALCULATOR... lets get started" << endl << endl;
}
};
int main()
{
setup setapp1;
setapp1.title();
system("TITLE calculator");
system("color 2");
double a;
double b;
char cchar;
char cagain;
do{
system("CLS");
cout << "please enter the first number you want to use" << endl;
cin >> a;
cout << "please enter the number you would like to use" << endl;
cin >> cchar;
cout << "please enter the second number you would like to use" << endl;
cin >> b;
switch (cchar){
case'+':
cout << "the answer is: " << a << " + " << b << " = "
<< (a + b) << endl;
break;
case'-':
cout << "the answer is: " << a << " - " << b << " = "
<< (a - b) << endl;
break;
case'*':
cout << "the answer is: " << a << " * " << b << " = "
<< (a * b) << endl;
break;
case'/':
cout << "the answer is: " << a << " / " << b << " = "
<< (a / b) << endl;
break;
default:
cout << "you cant use that operation";
break;
}
cout << "would you like to start again (y or n)";
cin >> cagain;
}while (cagain == 'y' || cagain == 'Y');
system("pause");
return 0;
}