rendered paste body/**********************************************
* Name: Greg Holle *
* Date: 4/17/06 *
* Assignment: Project 8: *
***********************************************
*
***********************************************/
#include <iostream>
#include <string>
#include <stdio.h>
//#include "number.h"
using namespace std;
int main() {
char buffer[50];
char *token;
string input[2];
string inputformat[2];
string operation="NULL";
string format="Integer";
int count = 0;
cout << "Enter an arithmetic expression: ";
cin.getline(buffer, 49);
for(int x=0; x<50; x++){
if (buffer[x]=='+'){
operation="+";
}
else if (buffer[x]=='-'){
operation="-";
}
else if (buffer[x]=='*'){
operation="*";
}
if (buffer[x]=='/'){
if (format=="decimal"){
//do nothing
}
else{
format="fraction";
}
}
else if (buffer[x]=='.'){
format="decimal";
}
}
token = strtok(buffer, " +-*");
while(token != NULL) {
input[count]= token;
count++;
if (count==3){
cout<<"Incorrect formatting. Program ending.\nPress any key to continue."<<endl;
cin.getline(buffer,1);
return(0);
}
token = strtok(NULL, " +-*");
}
for(int x=0; x<2; x++){
if (input[x].find("/",0) !=string::npos){
inputformat[x]="fractional";
}
else if (input[x].find(".",0) !=string::npos){
inputformat[x]="decimal";
}
else{
inputformat[x]="integer";
}
}
double number;
if (operation=="+"){
}
else if (operation=="-"){
}
else if (operation=="*"){
}
else{
cout<<"Incorrect formatting. Program ending.\nPress any key to continue."<<endl;
}
cout<<input[0]+" "+inputformat[0]<<endl;
cout<<input[1]+" "+inputformat[1]<<endl;
cout<<input[0]+operation+input[1]<<" Formating:"<<format<<endl;
cin.getline(buffer,1);
return 0;
}