![]() |
|
#1
|
|||
|
|||
fraction class programPrepare the Fraction class as we discussed in the classroom. It should include three constructors -- one with no parameters and which creates the fraction 0/1, one with one parameter numer and which creates the fraction numer/1, and one with two parameters and which creates the fraction numer/denom, but which assures that the fraction will be in normalized form (that is, positive denominator and with the greatest common divisor removed from the numerator and denominator). Make sure that the store method also stores fractions in normalized form. Add two public methods (functions) to the class, called getNumerator and getDenominator, that return the values of the numerator and denominator of the fraction. The header file and implementation files should be separate files!!
Write a main program to test the fraction class. This main program should first create three fractions to test the three types of constructors. Have the fractions print themselves, but precede each with an explanatory remark so that a fraction doesn't appear by itself. Then prompt the user to enter a numerator and a denominator. Store that fraction in the fraction that you first created with no parameters. Have it print itself. Ask the user if he/she wants to enter another fraction. If N or n is answered, then quit this part of the program and go on to the final step (below). If Y or y is entered, then ask for another fraction, store it and print it. Repeat until the user answers N or n, and then move to the final step. (If the user enters a zero denominator, the constructor and the store method should detect this and take an exit from the program.) As a final step, create the three fractions fract1, fract2 and fract3, where fract1 contains 5/6, fract2 contains 7/2 and fract3 is just the default fraction. Use the getNumerator and getDenominator functions to obtain the numerators and denominators of fract1 and fract2, and store in fract3 the sum of fract1 and fract2. Note: a/b + c/d = (a*d + c*b) / (b*d). Then have fract3 print itself to make sure the correct result was stored. CPP / C++ / C Code:
could anybody help me out with what you see im missing. i am getting overwhelmed and maybe with a few godd pointers ic an get set right again thanks |
|
#2
|
|||
|
|||
Re: fraction class programplease can somebody help me with this i am really confused in what to do next can somebody point me in the right direction? thanks
|
|
#3
|
|||
|
|||
Re: fraction class programPlease read the guidelines.
#2.2 to 2.4 describes what you did NOT do. We don't know what to tell you. #7 is self explanitory. __________________
Please read http://www.gidforums.com/t-5566.html. They were written to help you create a request that is readable and has enough information we can actually tell what you need help with. |
|
#4
|
|||
|
|||
Re: fraction class programQuote:
it compiles fine i need help trying to figure out what i am lacking from what the instructions say to do. sorry i didnt make that clearer. |
|
#5
|
||||
|
||||
Re: fraction class programQuote:
Can't really do more than that. If you've read the Guidelines you know we'll help you fix coding errors, help you understand something you don't, but we usually don't analyze code just as a exercise. If you have specific questions, we can definitely help in that regard. __________________
Age is unimportant -- except in cheese |
|
#6
|
|||
|
|||
Re: fraction class programok well heres the question i am having trouble with right now. i need to add to public functions in the header file named getnumerator and getdenominator, but how would i write it out in the implementation file to work with the whole program is what i am having problems with. thanks
|
|
#7
|
||||
|
||||
Re: fraction class programQuote:
__________________
Don't walk in front of me, I may not follow. Don't walk behind me, I may not lead. Just walk beside me and be my friend. |
|
#8
|
||||
|
||||
Re: fraction class programQuote:
If so, study them to see how they did it and use similar coding techniques. If not, you need to ask a more detailed question. __________________
Age is unimportant -- except in cheese |
Recent GIDBlog
Meeting the populace by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Fraction program | SpudNuts | C++ Forum | 6 | 25-Sep-2006 03:50 |
| Type casts ? | kai85 | C++ Forum | 12 | 23-Jun-2005 12:04 |
| Error C2146: syntax error : missing ',' before identifier 'C4' | mattchew008 | C++ Forum | 2 | 19-Dec-2004 06:06 |
| fltk-2.0 cvs | Plumb | FLTK Forum | 20 | 13-Nov-2004 07:10 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The