hai

just made this code and i look through it many time.. i cant figure out why it isint woking.. any suggestions ?

#include<iostream>
using namespace std;

int main();
{
	system ("TITLE calc");
	system ("COLOR 5");
	char cChar;
	double dfistnumber;
	double dsecondnumber;
	char cDoagain;

	do 
	{
		system ("CLS");

		cout << "please enter 1st number that you would like to use" << endl;
		cin >> dfirstnubmer;
		cout << "please enter the operation you would like to complete" << endl
			<< " (+,-,* or /)" << endl;
		cin >> cChar;

		cout << "please enter the 2n number you would like to use" << endl;
		cin >> dsecondnumber;

		switch (cChar)
		{

		case '+':
			cout << "the answer is: " << dfirstnumber << " + " 
				<< dsecondnumber << " - " << (dfirstnumber + dsecondnumber << endl;
			break;

		case '-':
			cout << "the answer is: " << dfirstnumber << " - " 
				<< dsecondnumber << " - " << (dfirstnumber + dsecondnumber << endl;
			break;

		case '*':
			cout << "the answer is: " << dfirstnumber << " * " 
				<< dsecondnumber << " - " << (dfirstnumber * dsecondnumber << endl;
			break;
	
		case '/':
			if (dsecondnumber == 0){
				cout << "nice try, but no" << endl; }
			if (dfirstnumber == 0){
				cout << "nice try, but no" << endl; }
			else{
			cout << "the answer is: " << dfirstnumber << " / " 
				<< dsecondnumber << " - " << (dfirstnumber / dsecondnumber << endl;
				}
		
	default:
		cout << "that is an invalid operation, tard" << endl;
		break;
	}

	cout << "wana try again ? (y/n)" << endl;
	cin >> cDoagain;
} while (cDoagain == 'Y' || cDoagain == 'y');

system ("pause");
return 0;
}

i would appreciate any kind of help..

hi
in line 4 remove the semicolon after the main

please mark it as solved

Didn't help. Got just more errors. :P

Care to elaborate on the errors? We're not mind-readers.

Looks like you need to pay closer attention to your variable names. I can see several instances of variable names not matching.

On Line 9, you declare a double called "dfistnumber". It seems you want to input to it on Line 18, but you are trying to input to "dfirstnumber". Notice the different spelling?

and you have to fix this problems
change this

double dfistnumber;

to

double dfirstnumber;

and

case '+':
			cout << "the answer is: " << dfirstnumber << " + " 
				<< dsecondnumber << " - " << (dfirstnumber + dsecondnumber << endl;

to

case '+':
			cout << "the answer is: " << dfirstnumber << " + " 
				<< dsecondnumber << " - " << (dfirstnumber + dsecondnumber) << endl;

and this

cin >> dfirstnubmer;

to this

cin >> dfirstnumber;

this one

case '-':
			cout << "the answer is: " << dfirstnumber << " - " 
				<< dsecondnumber << " - " << (dfirstnumber + dsecondnumber << endl;
			break;

to

case '-':
			cout << "the answer is: " << dfirstnumber << " - " 
				<< dsecondnumber << " - " << (dfirstnumber + dsecondnumber) << endl;
			break;

this

case '*':
			cout << "the answer is: " << dfirstnumber << " * " 
				<< dsecondnumber << " - " << (dfirstnumber * dsecondnumber << endl;
			break;

to

case '*':
			cout << "the answer is: " << dfirstnumber << " * " 
				<< dsecondnumber << " - " << (dfirstnumber * dsecondnumber )<< endl;
			break;

also

case '/':
			if (dsecondnumber == 0){
				cout << "nice try, but no" << endl; }
			if (dfirstnumber == 0){
				cout << "nice try, but no" << endl; }
			else{
			cout << "the answer is: " << dfirstnumber << " / " 
				<< dsecondnumber << " - " << (dfirstnumber / dsecondnumber << endl;
				}

to

case '/':
			if (dsecondnumber == 0){
				cout << "nice try, but no" << endl; }
			if (dfirstnumber == 0){
				cout << "nice try, but no" << endl; }
			else{
			cout << "the answer is: " << dfirstnumber << " / " 
				<< dsecondnumber << " - " << (dfirstnumber / dsecondnumber) << endl;
				}

and done

1>------ Build started: Project: calc, Configuration: Debug Win32 ------
1> main.cpp
1>c:\users\blenor\documents\visual studio 2010\projects\calc\calc\main.cpp(31): error C2563: mismatch in formal parameter list
1>c:\users\blenor\documents\visual studio 2010\projects\calc\calc\main.cpp(31): error C2568: '<<' : unable to resolve function overload
1> c:\program files\microsoft visual studio 10.0\vc\include\ostream(1021): could be 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1> with
1> [
1> _Elem=unsigned short,
1> _Traits=std::char_traits<unsigned short>
1> ]
1> c:\program files\microsoft visual studio 10.0\vc\include\ostream(1011): or 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1> with
1> [
1> _Elem=wchar_t,
1> _Traits=std::char_traits<wchar_t>
1> ]
1> c:\program files\microsoft visual studio 10.0\vc\include\ostream(1003): or 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 10.0\vc\include\ostream(977): or 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1>c:\users\blenor\documents\visual studio 2010\projects\calc\calc\main.cpp(31): error C2143: syntax error : missing ')' before ';'
1>c:\users\blenor\documents\visual studio 2010\projects\calc\calc\main.cpp(36): error C2563: mismatch in formal parameter list
1>c:\users\blenor\documents\visual studio 2010\projects\calc\calc\main.cpp(36): error C2568: '<<' : unable to resolve function overload
1> c:\program files\microsoft visual studio 10.0\vc\include\ostream(1021): could be 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1> with
1> [
1> _Elem=unsigned short,
1> _Traits=std::char_traits<unsigned short>
1> ]
1> c:\program files\microsoft visual studio 10.0\vc\include\ostream(1011): or 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1> with
1> [
1> _Elem=wchar_t,
1> _Traits=std::char_traits<wchar_t>
1> ]
1> c:\program files\microsoft visual studio 10.0\vc\include\ostream(1003): or 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 10.0\vc\include\ostream(977): or 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1>c:\users\blenor\documents\visual studio 2010\projects\calc\calc\main.cpp(36): error C2143: syntax error : missing ')' before ';'
1>c:\users\blenor\documents\visual studio 2010\projects\calc\calc\main.cpp(41): error C2563: mismatch in formal parameter list
1>c:\users\blenor\documents\visual studio 2010\projects\calc\calc\main.cpp(41): error C2568: '<<' : unable to resolve function overload
1> c:\program files\microsoft visual studio 10.0\vc\include\ostream(1021): could be 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1> with
1> [
1> _Elem=unsigned short,
1> _Traits=std::char_traits<unsigned short>
1> ]
1> c:\program files\microsoft visual studio 10.0\vc\include\ostream(1011): or 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1> with
1> [
1> _Elem=wchar_t,
1> _Traits=std::char_traits<wchar_t>
1> ]
1> c:\program files\microsoft visual studio 10.0\vc\include\ostream(1003): or 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 10.0\vc\include\ostream(977): or 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1>c:\users\blenor\documents\visual studio 2010\projects\calc\calc\main.cpp(41): error C2143: syntax error : missing ')' before ';'
1>c:\users\blenor\documents\visual studio 2010\projects\calc\calc\main.cpp(51): error C2563: mismatch in formal parameter list
1>c:\users\blenor\documents\visual studio 2010\projects\calc\calc\main.cpp(51): error C2568: '<<' : unable to resolve function overload
1> c:\program files\microsoft visual studio 10.0\vc\include\ostream(1021): could be 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1> with
1> [
1> _Elem=unsigned short,
1> _Traits=std::char_traits<unsigned short>
1> ]
1> c:\program files\microsoft visual studio 10.0\vc\include\ostream(1011): or 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1> with
1> [
1> _Elem=wchar_t,
1> _Traits=std::char_traits<wchar_t>
1> ]
1> c:\program files\microsoft visual studio 10.0\vc\include\ostream(1003): or 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 10.0\vc\include\ostream(977): or 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1>c:\users\blenor\documents\visual studio 2010\projects\calc\calc\main.cpp(51): error C2143: syntax error : missing ')' before ';'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

after removing semicolon

1>------ Build started: Project: calc, Configuration: Debug Win32 ------
1> main.cpp
1>c:\users\blenor\documents\visual studio 2010\projects\calc\calc\main.cpp(5): error C2447: '{' : missing function header (old-style formal list?)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

befor removing semicolon

EDIT

i fixed spelling.. error still remains..

You only got the 1 error when you had the semi-colon because the compiler didn't know what to do with the statement block after it so it essentially ignored it.

Once you removed the semi-colon, the compiler was able to "see" the rest of your code. It is now necessary for you to fix the errors it reports. Refer to our posts above yours for some items. There may be more.

in your function calls there's a missing ")" in each call put them as i did in my previous post . it worked with me . try it

Oh. I see it now. Such a trivial error. Im very thankful for help.

you're welcome
please mark it as solved

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.