makining those changes
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
|
#include <cstdlib>
#include <cstdio>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
void Welcome_screen(); {
cout << "Weclome to Adriann's C++ Simple Calculator.\n";
float input_check() {
float num;
while(1) {
if (cin >> num) {
break;
}
if(cin.fail()) {
cout << "Numerical value needed !! Try again: ";
cin.clear();
cin.ignore( 1024, '\n' );
}
}
}
return num;
}
float Plus (float num1, float num2) { return num1+num2; }
float Minus (float num1, float num2) { return num1-num2; }
float Multiply(float num1, float num2) { return num1*num2; }
float Divide (float num1, float num2) { return num1/num2; }
int main() {
char controller;
float num1=0;
float num2=0;
char myoperator;
float result=0;
do {
Welcome_screen();
cout << "\nEnter your first number: ";
num1 = input_check();
cout << "\nEnter the operator: ";
cin >> myoperator;
cout << "\nEnter second number: ";
num2 = input_check();
switch(myoperator) {
case '+' : result = Plus (num1, num2); break;
case '-' : result = Minus (num1, num2); break;
case '*' : result = Multiply (num1, num2); break;
case '/' : result = Divide (num1, num2); break;
default : cout << "Sorry, this is a BASIC calculator ;)\n";
}
cout << '\n' << result << "\n";
cout << "Type any key and ENTER to contunue or N ENTER to quit ...:";
cin >> controller;
system("clear");
} while(controller != 'N');
cout << "Thanks for using my basic calculator !! \n Goodbye :D\n";
return 0;
|
Still gives me these errors
1>------ Build started: Project: calc2, Configuration: Debug Win32 ------
1> calc2.cpp
1>c:\users\adriann\documents\c++\calc2\calc2\calc2.cpp(25): error C2601: 'input_check' : local function definitions are illegal
1> c:\users\adriann\documents\c++\calc2\calc2\calc2.cpp(22): this line contains a '{' which has not yet been matched
1>c:\users\adriann\documents\c++\calc2\calc2\calc2.cpp(38): error C2065: 'num' : undeclared identifier
1>c:\users\adriann\documents\c++\calc2\calc2\calc2.cpp(41): error C2601: 'Plus' : local function definitions are illegal
1> c:\users\adriann\documents\c++\calc2\calc2\calc2.cpp(21): this line contains a '{' which has not yet been matched
1>c:\users\adriann\documents\c++\calc2\calc2\calc2.cpp(42): error C2601: 'Minus' : local function definitions are illegal
1> c:\users\adriann\documents\c++\calc2\calc2\calc2.cpp(21): this line contains a '{' which has not yet been matched
1>c:\users\adriann\documents\c++\calc2\calc2\calc2.cpp(43): error C2601: 'Multiply' : local function definitions are illegal
1> c:\users\adriann\documents\c++\calc2\calc2\calc2.cpp(21): this line contains a '{' which has not yet been matched
1>c:\users\adriann\documents\c++\calc2\calc2\calc2.cpp(44): error C2601: 'Divide' : local function definitions are illegal
1> c:\users\adriann\documents\c++\calc2\calc2\calc2.cpp(21): this line contains a '{' which has not yet been matched
1>c:\users\adriann\documents\c++\calc2\calc2\calc2.cpp(46): error C2601: 'main' : local function definitions are illegal
1> c:\users\adriann\documents\c++\calc2\calc2\calc2.cpp(21): this line contains a '{' which has not yet been matched
1>c:\users\adriann\documents\c++\calc2\calc2\calc2.cpp(75): fatal error C1075: end of file found before the left brace '{' at 'c:\users\adriann\documents\c++\calc2\calc2\calc2.cpp(46)' was matched
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========