I cannot figure this out...when i cout<<solve; it comes up some crazy number...like it has been assigned no value ever???? I don't know what I'm doing wrong?????
Here is my program:
//PROBLEM: math choice
#include <iostream.h>
#include <conio.h>
#include <iomanip.h>
#include <string.h>
float adding(a,b){return float(a+b);};
float subtract(a,b){return float(a-b);};
float multiply(a,b){return float(a*b);};
float divided(a,b){return float(a/b);};
int main(){
float a,b,solve;
char sign,answer;
do{
cout<<"Please enter your mathematical"<<endl;
cout<<"expression: ";
cin>>a;
cin>>sign;
cin>>b;
switch (sign){
case '+': { solve=(adding(a,b));
break;}
case '-': { solve=(subtract(a,b));
break;}
case '*': {solve=(multiply(a,b));
break;}
case '/': { solve=(divided(a,b));
break;}
default : {cout<<"Please choose either +,-,*, or /."<<endl;
solve=0;}}
if((sign=='+')||(sign=='-')||(sign=='*')||(sign=='/')){
cout.setf(ios::showpoint);
cout.setf(ios::fixed);
cout<<"Your expression, ";
cout<<setprecision(2)<<a<<sign<<b<<" = "<<solve<<endl;}
cout<<"Would you like to enter another expression?"<<endl;
cout<<"Enter 'y' for yes and 'n' for no. Answer: ";
cin>>answer;
}while(answer=='y');
getch();
return 0;}
Somebody Please Tell me how to do this...My teacher is an idiot and has no idea either....I need some help!!!!!