Rational class performs operations on fractions

Assignment Help C/C++ Programming
Reference no: EM13700779

Question: Rational fractions are of the form a/b , where a and b are integers and b ? 0. Suppose a / b and c / d are fractions.

Arithmetic operations on fractions are defined by the subsequent rules:

a / b + c / d = (ad + bc) / bd

a / b - c / d = (ad - bc) / bd

a / b * c / d =  ac / bd

(a / b)  / (c / d) = ad / bc, where c/d ? 0.

Fractions are compared as follows:

a / b   op   c/d   if   ad   op  bc, where op is any relational operator. For example,  a/b  <  c/d if  ad < bc.

Part 1: Create a class, called Rational, for performing arithmetic and relational operations on fractions.

Use integer variables to represent the private instance variables of the class - the numerator and the denominator.

Provide a constructor method that allows an object of this class to be initialized when it is declared. The constructor should store the fraction in reduced form (i.e. the fraction 2/4 would be stored as 1 in the numerator and 2 in the denominator). Provide a no-argument constructor in case no initializers are provided.

a. Overload the arithmetic operators ( +, -, *, / ) , so that the suitable symbol can be used to perform these operations. The result of each operation should be in reduced form.

b. Overload the relational operators ( <, <=, >, >=, ==, != ) , so that the appropriate symbol can be used to perform these operations.

c. Overload the stream insertion and stream extraction operators for input and output.

Part 2: Write a C++ program that, using the rational class performs operations on fractions. Test your class thoroughly.

Show the constructor method and overload the stream insertion and stream extraction operators

Reference no: EM13700779

Questions Cloud

How many moles of sbcl5 and sbcl3 : Question- Starting with 0.290mol SbCl3 and 0.170mol Cl2, how many moles of SbCl5, SbCl3, and Cl2 are present when equilibrium is established at 248?C in a 2.50?L flask?
Covert the subsequent decimal numbers into binary numbers : Write the results of the two numbers (in decimal) after the BIT operations and please covert the subsequent decimal numbers into binary numbers:  (using 2 bytes = 16 bits)
Calculate the heat needed to raise the temperature : Question- The specific heat of aluminum is 0.900J/g degrees C. Calculate the heat needed to raise the temperature of a 45.0 g block of aluminum from 20.5 degrees C to 297.4 degrees C
What is the maximum number of moles of al2o3 : Question- If 4.5 moles of Al and 3.3 moles of Fe2O3 are allowed to react, what is the maximum number of moles of Al2O3 that can be produced
Rational class performs operations on fractions : Write a C++ program that, using the rational class performs operations on fractions. Test your class thoroughly.
What compounds result from the reaction : Question- What happens to sodium azide when it is dissolved in water? What compounds result from this reaction?
Design an adt for a two color double stack : Design an adt for a two color double stack adt that consists of two stacks one red and one blue and has its operations color coded versions of the regular stack adt operations.
The oxidation number of chlorine goes from what to what : Question- As the reaction represented above proceeds to the right, the oxidation number of chlorine goes from what to what
Crossing a canyon on a cable bridge : Construct a Prolog program using in-depth research to find a solution to this problem. It must compile with no errors and follow the directions.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd