- Category:
- Java Develop
- Tags:
-
- File Size:
- 1kb
- Update:
- 2018-03-10
- Downloads:
- 0 Times
- Uploaded by:
- 可爱的你ff
Description: Create a fractional class Rational, used to perform arithmetic operations for fractions, and write a program to test the class.
(1) the class has two member variables, that is, molecules and denominator, all of which are integral types
(2) define a constructor to initialize the class object. The constructor must reduce the input parameters. For example, if a given fraction is 2/4 (i.e. the molecule is 2, the denominator is 4), we need to reduce it to 1/2, and then store it in the corresponding member variable, that is, the molecule is 1 and the denominator is 2.
(3) a add member function is defined to implement the addition of two fractions, and the result should also be reduced.
(4) a sub member function is defined to implement a subtraction of two fractions, and the result is reduced form.
To Search:
File list (Check if you may need any files):
Filename | Size | Date |
---|
rational | 0 | 2018-03-10
|
rational\Rational.java | 2343 | 2018-03-10
|
rational\Test.java | 585 | 2018-03-10 |