Define a class for rational numbers

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

Rational NUMBER

Define a class for rational numbers. A rational number is a number that can be represented as the quotient of two integers. For example, 1/2, 3/4, 64/2, and so forth are all rational numbers. (By ½, etc we mean the everyday meaning of the fraction, not the integer division this expression would produce in a C++ program).

Represent rational numbers as two values of type int, one for the numerator and one for the denominator. Call the class rationalNum

Include a constructor with two arguments that can be used to set the member variables of an object to any legitimate value. Also include a constructor that has only a single parameter of type int; call this single parameter whole_number and define the constructor so that the object will be initialized to the rational number whole_number/1. Also include a default constructor that initializes an object to 0 (that is, to 0/1).

Overload the input and output operators >> and <<. Numbers are to be input and output in the form 1/2, 15/32, 300/401, and so forth. Note that the numerator, the denominator, or both may contain a minus sign, so -1/2, 15/32, -300/-400 are all possible input. The input operator, >>, reads the string 15/32 as

Overload all of the following operators so that they correctly apply to the type rationalNum: ==, <, >, +, -, *, and /.

Write a test program to test your class.

Reference no: EM131184388

Questions Cloud

Describe strategic planning techniques : Describe strategic planning techniques used to formulate alternative strategies designed to achieve stated business goals.
What is the difference between a database and a table : What is the difference between a database and a table? What two conditions must be met before an entity can be classified as a weak entity? Give an example of a weak entity.
Who is associated with the gestalt school of psychology : Of the following, who is associated with the Gestalt school of psychology? Comparative psychologists are primarily interested in
Calculate the magnitude and direction of the polarization : A line of charge with line charge density PI C/m is placed at the center of the inner shell. Calculate the magnitude and direction of the polarization vector inside the two dielectrics.
Define a class for rational numbers : Define a class for rational numbers. A rational number is a number that can be represented as the quotient of two integers. For example, 1/2, 3/4, 64/2, and so forth are all rational numbers.
Design an amplifier to have nominal closed-loop gain : If component value variation in the B network may produce as much as ±1% variation in B, to whatvalue must A be raised to ensure the required minimum gain?
Discuss the types of mangers that your business will need : Discuss the types of mangers that your business will need. -  What types of teams will they need to manage in order to positively impact the business?
How do you see technology impacting the future of education : Read "Evaluating the Effectiveness of Technology in Our Schools" and "Technology in the Classroom." How do you see technology impacting the future of education
Write a detail document about the various business rules : Identify the appropriate relationships among the entities and define the minimum and maximum cardinality of each relationship. Make some additional assumptions about the business rules if necessary.

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