Reference no: EM13937643
Design a C++ program containing a class Fraction. The class data should have two variables numerator and denominator, both of type integer, to represent the fraction numerator/denominator. The fraction representation within the object must allow no simplification. That is, the numerator and denominator have to have no common divisor different from 1. For example, the fraction 4/6 must be represented as 2/3.
Be sure to implement the following features:
1. The class constructor must take two integers numbers (numerator and denominator).
2. For negative fractions, the numerator must be negative and denominator must be positive.
3. Include the method simplify that takes two numbers and returns a fraction object (representing a fraction that cannot be simplified).
4. Include a method add that takes two fraction objects and returns their sum (as a fraction object).
5. Include a method diff that takes two fraction objects and returns their difference (as a fraction object).
6. Implement overloaded operators + and - for addition and subtraction of fractions.
7. Implement overloaded comparison operators == and != for comparing two fraction objects.
Test your class in the main() method by creating several fractions, adding them, subtracting them, and printing the result by using the / sign (e.g., 2/3), not as decimal fractions. Also demonstrate usage of the overloaded operators.
Write a c++ code for sum of two large integers
: Write a C++ code for sum of two large integers. User have to enter two integers one by one.
|
Require an increase in net working capital
: McGilla Golf has decided to sell a new line of golf clubs. The length of this project is seven years. The company has spent $1796356 on research and development for the new clubs. The plant and equipment required will cost $28141541 and will be depre..
|
Prepare shareholders equity section of marbles balance sheet
: On October 1, 2006, Marble Company had 400,000 shares of $2 par common stock issued and outstanding. Prepare the shareholders' equity section of Marble's balance sheet at September 30, 2007.
|
What is the companys expected growth rate
: Kahn Inc. has a target capital structure of 50% common equity and 50% debt to fund its $10 billion in operating assets. Furthermore, Kahn Inc. has a WACC of 14%, a before-tax cost of debt of 11%, and a tax rate of 40%. What is the company's expected ..
|
Design a c++ program containing a class fraction.
: Test your class in the main() method by creating several fractions, adding them, subtracting them, and printing the result by using the / sign (e.g., 2/3), not as decimal fractions. Also demonstrate usage of the overloaded operators.
|
Why is sustained inflation a purely monetary phenomenon
: Why is sustained inflation a purely monetary phenomenon? Why is an increase in foreign exchange reserves recorded as a debit (-) item in the balance of payments?
|
What is initial cost of project including flotation costs
: Western Wear is considering a project that requires an initial investment of $260,000. The firm maintains a debt-equity ratio of .40 and has a flotation cost of debt of 8 percent and a flotation cost of equity of 10.5 percent. The firm has sufficient..
|
What was the average issue price of the stock issued
: What was the average issue price of the stock issued during 2007? What was the amount of dividends declared during 2007? Did the company have any treasury shares at the end of 2007?
|
What is the payback period for this project
: McGilla Golf has decided to sell a new line of golf clubs. The length of this project is seven years. The company has spent $1915230 on research and development for the new clubs. The plant and equipment required will cost $28720691 and will be depre..
|