Sigh... Here is the program:
/* Number Identifyer
Char :: ASCII
1-9 :: 48-57
A-Z :: 65-90
e :: 101
^ :: 94
. :: 46
*/
#include
using namespace std;
void spcRmv(char line[30]){ //Removes spaces.
int a=0;
int i=0;
for(;i if(line[i] != 32) line[a++] = line[i];
for(;a line[a]=0;
}
int chkTp(char line[30]){ // Checks type
int a=0;
int i=0;
if(line[a] != 0){
for(;i if(line[i] == \'.\') return 1; // Return \"1\" if line is fractional decimal.
if(line[strlen(line)]) return 2; // Return \"2\" if line is decimal.
}}
else return 3; //!!!!!!!!!!!!!TO BE EXPANDED ON!!!!!!!!!!!!!
}
void cnvrtDec(char line[30]){
int i=0;
int n1; //Used to hold upcoming change.
int n2=0; //Used to hold curent value;
int x=1; //Used for conversion.
for(;i n1 = line[i] - 48;
n2 = (n2 * x) + n1;
}
cout << \"\\n\\nValue Entered: \" << line;
cout << \"\\nValue Type: Decimal\";
cout << \"\\nDecimal Value: \" << n2;
cout << \"\\n\\n\";
}
int main()
{
char impLine[30]; //For imput.
for(;;){ //Controls entire program.
for(int chk;;){ // Input value.
cout << \"Input value: \";
gets(impLine);
for(int i=0; i if((48 <= impLine[i] <= 57) || (65 <= impLine[i] <= 90) || (impLine[i] == 101 || 94 || 46 || 32));
else { chk=1; break;} // If wrong value is given.
}
if(chk == 1){cout << \"\\nAlowed values: 1-9, e, ^, A-Z & .\\n\\n\"; continue;}
else;
if(strlen(impLine)<29) break; // Makes sure string size is 30 or less characters.
cout << \"\\nNo more than 30 characters!\\n\\n\";
}
cout << \"\\n\\n\";
spcRmv(impLine);
if(chkTp(impLine) == 1) continue; //Imput value identified as fraction (!!!NOT YET SUPORTED!!!)
else if(chkTp(impLine) == 2) cnvrtDec(impLine); //Imput value identified as decimal, and shall be converted.
else continue; //No more values yet suported!!!
}
return 0;
}
All it does it take the value that you imput, and tells you about it (What you entered, Type of value, Equivalent Decimal value).
Eventualy I\'m trying to get it to suport Decimals, Octals, Hex, Fractions, and Exponentials. But as of now the program is bearly breathing and I don\'t know why... Help?