I am not only new here, but, I am a complete newbie to programing. I was on the hunt for some beginner tutorials today on the web. I found what I thought would be a simple yet in depth problem. I spent the last hour making sure that I had typed everything exactly as instructed (you tube video) and when I tried to compile, MSVC++EXS came back with about twenty errors. Now I saw the code run on the video, so I feel confident that it should work. But no dice here. I will post both a link to the original and the code as follows:
Video link(s) http://www.youtube.com/watch?v=FPKmFdNP5_A&feature=related
my code;
// This is a program about loops, switch statements, ifelse statements
//and applying them to another faily simple programme.
#include <iostream>;
using namespace std;
int main ()
{
system ("TITLE Calculator");
system ("COLOR 2");
char cChar;
double dfirstnumber;
double dsecondnumber;
char cDoagain;
do
{
system ("CLS");
cout<< "Please enter the first number that you would like to use." << endl;
cin>> dfistnubmer;
cout<< "Please enter the operation that you would like to complete."
<<" (+,-,* and /)"<< endl;
cin>> cChar;
cin<< ("Please enter the second number that you would like to use.") << endl;
switch (cChar);
{
case "+";
cout<< " The Answer is:"<< dfirstnumber << "+" << dsecondnumber
<< dfirstnumber << "=" << dfirstnumber + dsecondnumber
<< endl;
case "-";
cout<< " The Answer is:"<< dfirstnumber << "-" << dsecondnumber
<< dfirstnumber << "=" << dfirstnumber - dsecondnumber
<< endl;
break;
case "*";
cout<< " The Answer is:"<< dfirstnumber << "*" << dsecondnumber
<< dfirstnumber << "=" << dfirstnumber * dsecondnumber
<< endl;
break;
case "x";
cout<< " The Answer is:"<< dfirstnumber << "x" << dsecondnumber
<< dfirstnumber << "=" << dfirstnumber * dsecondnumber
<< endl;
break;
case "X";
cout<< " The Answer is:"<< dfirstnumber << "X" << dsecondnumber
<< dfirstnumber << "=" << dfirstnumber * dsecondnumber
<< endl;
break;
case "/";
if (dsecondnumber == 0) {
cout << " That is an invalid operation!" << endl;
}else {
cout<< " The Answer is:"<< dfirstnumber << "/" << dsecondnumber
<< dfirstnumber << "=" << dfirstnumber / dsecondnumber
<< endl;
}
break;
default:
cout<< " That is an invalid operation" << endl;
break;
{
cout<< " Would you like to start again? (Y or N)" << endl;
cin>> cDoagain;
}while (cDoagain == 'Y' || cDoagain == 'y');
system ("Pause");
return 0;
}
Also I thought that I would include the error log so that some one might possible explain what it is that the program is talking about and possible way to fix them.
Error Log
Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\Makefile.win"
Executing make...
make.exe -f "C:\Dev-Cpp\Makefile.win" all
g++.exe -c switches.cpp -o switches.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include"
switches.cpp:4:20: warning: extra tokens at end of #include directive
switches.cpp: In function `int main()':
switches.cpp:20: error: `dfistnubmer' undeclared (first use this function)
switches.cpp:20: error: (Each undeclared identifier is reported only once for each function it appears in.)
switches.cpp:24: error: no match for 'operator<<' in 'std::cin << "Please enter the second number that you would like to use."'
switches.cpp:28: error: case label `"+"' not within a switch statement
switches.cpp:28: error: expected `:' before ';' token
switches.cpp:33: error: case label `"-"' not within a switch statement
switches.cpp:33: error: expected `:' before ';' token
switches.cpp:38: error: case label `"*"' not within a switch statement
switches.cpp:38: error: expected `:' before ';' token
switches.cpp:43: error: case label `"x"' not within a switch statement
switches.cpp:43: error: expected `:' before ';' token
switches.cpp:48: error: case label `"X"' not within a switch statement
switches.cpp:48: error: expected `:' before ';' token
switches.cpp:53: error: case label `"/"' not within a switch statement
switches.cpp:53: error: expected `:' before ';' token
switches.cpp:62: error: case label not within a switch statement
switches.cpp:71: error: expected `}' at end of input
switches.cpp:71: error: expected `while' at end of input
switches.cpp:71: error: expected `(' at end of input
switches.cpp:71: error: expected primary-expression at end of input
switches.cpp:71: error: expected `)' at end of input
switches.cpp:71: error: expected `;' at end of input
switches.cpp:71: error: expected `}' at end of input
make.exe: *** [switches.o] Error 1
Execution terminated
If you all could assist me in find out how to fix the errors I would greatly appreciate the assistance.
Best
Archiphile