hey i have a problem with adding an is numeric checker to my code for my class when i hit a snag just wondering if i could get some help
this is my first program so help is appreciated
// fun with physics.cpp : Defines the entry point for the console application.
//INCLUDES
#include "stdafx.h"
#include <iostream>
using namespace std;
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <stdio.h>
#include "math.h"
#include <iomanip>
//FUNCTIONS
//MAIN
int main()
{
int isnum(const char *p)
{
if (*p) {
char c;
while ((c=*p++)) {
if (!isdigit(c)) return 0;
}
return 1;
}
return 0;
}
bool finished = false;
while(finished==false)
{
cout << "\n What equation do u want to use?";
cout << "\n1. Quadratic Equation";
cout << "\n2. Distance Formula";
cout << "\n3. Velocity Formula";
cout << "\n4. Acceleration Formula";
cout << "\n5. Dividing With Error";
cout << "\n6. RMS";
cout << "\n7. Squaring Error";
cout << "\n8. Multiplying With Error";
cout << "\nEnter the number of the program you wish to use!\n";
int o;
cin >> o;
if (o == 1)
{
cout << "Quadratic equation\n";
cout << "enter a: ";
float a;
cin >> a;
cout << "Enter b: ";
float b;
cin >> b;
cout << "Enter c: ";
float c;
cin >> c;
if (isnum(a)&& isnum
(b) && isnum(c) && a!=0) {
float z = pow (b,2);
float x = z - (4* a *c);
float y = sqrt (x);
float d= ( (-b + y) / (2*a));
float e= ( (-b - y) / (2*a));
cout << "\nYour answer is\n";
cout << d;
cout << "\n or \n";
cout << e;
cout << "\n";
}
else { cout << " please check your input\n";
}
}
if (o == 2)
{
cout << "Distance\n";
cout << "Enter Final Velocity:";
double x;
cin >> x;
cout << "Enter Initial Velocity:";
double y;
cin >> y;
cout << "Enter Time:";
double t;
cin >> t;
double d;
d = ((x+y)/2)*t;
cout << "Distance is\n";
cout <<"\n";
cout << d;
}
if (o == 3)
{
cout << "Velocity\n";
cout << "Enter Final Distance:";
double x;
cin >> x;
cout << "Enter Initial Distance:";
double y;
cin >> y;
cout << "Enter Time:";
double t;
cin >> t;
double d;
d = ((x-y)/t);
cout << "Velocity is\n";
cout << d;
cout << "\n";
}
if (o == 4)
{
cout << "Acceleration\n";
cout << "Enter Final veloctiy:";
double x;
cin >> x;
cout << "Enter Initial velocity:";
double y;
cin >> y;
cout << "Enter Time:";
double t;
cin >> t;
double d;
d = ((x-y)/t);
cout << "Acceleration is\n";
cout << d;
}
if (o == 5){
cout << "Enter A then error1\n";
float a;
cin >> a;
float e;
cin >> e;
cout << "Enter B then error2\n";
float b;
cin >> b;
float f;
cin >> f;
float z = a / b;
float y = ( e / a) * 100;
float ysquared = pow ( y, 2);
float p = (f / b) * 100;
float psquared = pow ( p, 2);
float c = (ysquared + psquared);
float i = sqrt (c);
float x = i / 100;
float q = z * x;
cout << "Your answer is\n" << z << "\n+ or -\n" << q;
cout << "\n";
}
if (o == 6)
{
cout << "Input x1 through x3.\n";
float b;
cin >> b;
float c;
cin >> c;
float d;
cin >> d;
float a;
a =((b + c + d) / 3);
float y =(b - a);
float x = pow (y,2);
float w = (c - a);
float z = pow (w,2);
float p = (d - a);
float j = pow (p,2);
float q = (x + z + j) / (6);
float T = sqrt (q);
cout << "Your answer is\n"<< a;
cout << "\n plus or minus \n";
cout << T <<"\n";
}
if (o == 7){
cout << "Enter number\n";
float a;
cin >> a;
cout << "Enter error\n";
float e;
cin >> e;
float b = pow (a,2);
float y = b * (2*(e/a));
cout << "Your answer is \n";
cout << b;
cout << "\n+ or -\n";
cout << y;
}
if (o == 8){
cout << "Enter first number\n";
float a;
cin >> a;
cout << "Enter error\n";
float b;
cin >> b;
cout << "Enter second number\n";
float c;
cin >> c;
cout << "Enter error\n";
float d;
cin >> d;
float e = (100*b/a);
float f = (100*d/c);
float z = pow (e,2);
float x = pow (f,2);
float y = z + x;
float v = sqrt (y);
float s = a * c;
cout << s;
cout << "\nwith a precent error of\n";
cout << v;
}
char tempChar;
cout << "Do you wish start the program again? [Y/N]: ";
cin >> tempChar;
if( tempChar == 'N' || tempChar == 'n' )
finished = true;
}
return 0;
}
errors:
------ Build started: Project: fun with physics, Configuration: Release Win32 ------
Compiling...
fun with physics.cpp
.\fun with physics.cpp(25) : error C2601: 'isnum' : local function definitions are illegal
.\fun with physics.cpp(22): this line contains a '{' which has not yet been matched
.\fun with physics.cpp(71) : error C2664: 'isnum' : cannot convert parameter 1 from 'float' to 'const char *'
.\fun with physics.cpp(72) : error C2664: 'isnum' : cannot convert parameter 1 from 'float' to 'const char *'
.\fun with physics.cpp(72) : error C2664: 'isnum' : cannot convert parameter 1 from 'float' to 'const char *'
Build log was saved at "file://\\nasserver2\cgrealish11\Documents\Visual Studio 2008\Projects\fun with physics\fun with physics\Release\BuildLog.htm"
fun with physics - 4 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========