Link to home
Start Free TrialLog in
Avatar of dude1337
dude1337

asked on

Using Fractions

I am writing a program that I need to be able to have the user input fractions such as 1/2 and output them to say 1/2 or 3/4.  Does anyone have any suggestions on how to do this?
Avatar of PlanetCpp
PlanetCpp

it would really help to know what you plan to do withy this input in between the input and output. you can take it in as a string. but more info is needed for any other options
Avatar of dude1337

ASKER

The user will input the fraction and it will be multiplied and divided in different ways, maybe some addition and I want it to show the output of the answer and the original entry they put in.
Dude, you're not trying to get easy answers for homework are you?  I hope not...  You need to state where you're at, and where you're stuck.  It really comes down to parsing strings into data, store them as objects, and then apply the rules of math to get your results, perhaps with a fraction simplification done as well.
brian
No, I am making a program that has nothing to do with homework.  It is a formula solving program to perform basic algebra formulas such as linear and quadratic formulas.  I am trying to get the user to input the sllope of a line, which most of the time is a fraction.  Then I have the program go through the point/slope formula and it ouputs the y-intercept and the slope again, which the user already put in.  That is why I need to use fractions because slope is easier to calculate as a fraction than a decimal.  I am doing this of my own free will.
ASKER CERTIFIED SOLUTION
Avatar of akshayxx
akshayxx
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>>>class struct fraction{

heheh didnt i tell u people that i am a C programmer .. and i dont know C++ :)
Thanks, this helps, but it was not a homework problem.
sorry .. but from the description of ur problem it looked like homework