Show Bid Request
RatioNumber
Bid Request Id: 4504
|
|
|
Description:
Create a workspace folder named 'RatioNumber'. In this project you will create a class 'Ratio' for performing arithmetic operations with fractions. The class definition, int main() function and standardize() function given below must be used with out modification in the assignment.
class Ratio {
public:
Ratio(int = 0, int = 1);
// default constructor
Ratio operator + (Ratio &);
// to perform x + y
Ratio operator - (Ratio &);
Ratio operator * (Ratio &);
Ratio operator / (Ratio &);
bool operator = = (Ratio &);
// for a/b and c/d, a/b = = c/d means a*d = = b*c friend ostream & operator << (ostream &, Ratio &):,
friend istream & operator >> (istream &, Ratio &);
private:
int numerator, denominator;
void standardize(); };
Call the class definition file as 'Ratio.h,' the function definition file as 'Ratio.cpp' and client file as 'RatioNumber.cpp.' Your client program must test the operators that you have defined in the class. The int main function must be the following.
int main()
{
Ratio x, y;
cout << “Enter a ratio in the form a/b: “;
cin >> x;
cout << “You have entered: x = “ << x << endl;
cout << "Enter a ratio in the form a/b: “;
cin >> y;
cout << "You have entered: y = ” << y<< endl;
cout << "x + y = “ << x+y << endl;
cout << "x - y = ” << x-y << endl;
cout << "x * y =” << x*y << endl;
cout << "x / y =” << x/y << endl;
if (x = = y) cout << x << “equal to “ << y << endl;
else
cout << x << “not equal to “ << y << endl;
return 0;
}
I could not fit all the assignment on this part the 2nd half is on the deliverables section
Deliverables: The standardize function is the following. void Ratio::standardize()
{
if (denominator < 0)
{ numerator = -numerator;
denominator = -denominator;
}
for (int i = denominator; i >= 2; i--)
if (numerator/ i *i == numerator && denominator/i*i == denominator)
{ // if i divides both numerator and denominator exactly then divide them by i numerator = numerator/i;
denominator = denominator/i;
}
A sample run of your program Enter a ratio in the form a/b: 2/6 You have entered: x = 1/3
Enter a ratio in the form a/b: 1/4 You have entered: y = 1/4
x + y = 7/12
x - y = 1/12
x * y = 1/12
x /y = 4/3
1/3 not equal to 1/4
Complete and fully-functional working program(s) in executable form as well as complete source code of all work done.
Special Conditions / Other:
It is due Tuesday Morning so I need it Monday evening if not sooner.
Remember that contacting the other party outside of the site (by email, phone, etc.) on all business projects < $500 (before the buyer's money is escrowed) is a violation of both the software buyer and seller agreements.
We monitor all site activity for such violations and can instantly expel transgressers on the spot, so we thank you in advance for your cooperation.
If you notice a violation please help out the site and report it. Thanks for your help.
|
|
Bidding/Comments:
|
All monetary amounts on the site are in United States dollars.
Rent a Coder is a closed auction, so coders can only see their own bids and comments. Buyers can view every posting made on their bid requests. |
See all rejected bids (and all comments)
Name |
Bid Amount |
Date |
Coder Rating |
|
|
|
This bid was accepted by the buyer!
|
$15 (USD)
|
Nov 4, 2001 11:05:08 AM EDT
|
10
(Excellent)
|
|
|
Hello J.R.Duke,
I can creating this project by continueing the previous Rational class I've done for you easily.
I can finish this in less than an hour.
Looking forward to your reply.
Best regards,
Sammy Leong</br> |
|
|
|
|
|