1. Engineering
  2. Computer Science
  3. please do create all 3 files rationalh rationalcpp and rationaltestcpp...

Question: please do create all 3 files rationalh rationalcpp and rationaltestcpp...

Question details

The goal of assignment 2 is to reinforce implementation of ADT concepts in C++. Specifically, the assignment is to do problem 2.15 on pages 94 of the text. Your code must implement the style guidelines of the author (preconditions, postconditions, etc.). Your solution needs to have 3 separate files. Please name the files as following: rational.h - Class definition or header file rational.cpp - Implementation file that contains all implemented functions of the rational class rational test.cpp - test file to test the rational class. Create at least 2 objects of the rational class and test ALL functions defined in the class. Make sure your output has proper labels for inputs as well as output. If you are working on your local machines, please make sure that your final code can be compiled and executed on the cloudland server.

S. Each 15 object in the class should have two integer values that define the rational number: the umerator and the denominator. For example, the raction 5/6 would have a denominator of 5 and a nu- merator of 6. Include a constructor with two argu- ments that can be used to set the numerator and 1 Write a class for rational numbers.

denominator (forbidding zero in the denominator). Provide default values of zero for the numerator and one for the denominator Overload the input and output operators. Num- bers are to be read and written in the form 1/2, 32/15, 300/401, and so forth. Note that the numer- ator, the denominator, or both may contain a minus sign, so -1/2, 32/-15, and-300/-401 are possible. Include a function to normalize the values stored so that, after normalization, the denominator is pos- itive and as small as possible. For example, after normalization, 4/-8 would be represented the same Overload the usual arithmetic operators to pro- vide addition, subtraction, multiplication, and divi- sion of two rational numbers. Overload the usual comparison operations to allow comparison of two rational numbers. Hints: Two rational numbers alb and cld are equal if a d equals c b. For positive rational num bers, alb is less than cld, provided a d is less than c b.

Please, do create all 3 files, rational.h, rational.cpp and rational_test.cpp.

thank you

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution