Print rational numbers in floating-point format

Assignment Help Basic Computer Science
Reference no: EM131610185

Question: (Rational Class) Create a class called Rational for performing arithmetic with fractions. Write a program to test your class. Use integer variables to represent the private data of the class-the numerator and the denominator. Provide a constructor that enables an object of this class to be initialized when it's declared. The constructor should contain default values in case no initializers are provided and should store the fraction in reduced form. For example, the fraction 2/4 would be stored in the object as 1 in the numerator and 2 in the denominator.

Provide public member functions that perform each of the following tasks:

a) Adding two Rational numbers. The result should be stored in reduced form.

b) Subtracting two Rational numbers. The result should be stored in reduced form.

c) Multiplying two Rational numbers. The result should be stored in reduced form.

d) Dividing two Rational numbers. The result should be stored in reduced form.

e) Printing Rational numbers in the form a/b, where a is the numerator and b is the denominator.

f) Printing Rational numbers in floating-point format.

Reference no: EM131610185

Questions Cloud

Explain the function and operation of cisco switch : Explain the function and operation of Cisco switch and router operating systems and their specific licensing, management, and operational recovery procedures.
What was average weekly allowance of a fourth-grade student : In a recent year, the average allowance of a 9th-grade student was 9.66 dollars per week. What was the average weekly allowance of a 4th-grade student?
Firm after incorporating the impact of the operating leases : what would be the debt ratio of the firm after incorporating the impact of the operating leases?
What is nodebts wacc and asset beta : Nodebt Inc. is a firm with all-equity financing. Its equity beta is .80. What is Nodebt’s asset beta? What is Nodebt’s WACC?
Print rational numbers in floating-point format : Create a class called Rational for performing arithmetic with fractions. Write a program to test your class. Use integer variables to represent the private.
Traditional versus object-oriented design : Compare the object-oriented approach to design to the traditional approach. Provide an example of one (1) such project.
Operating leases reported in the lessees balance sheet : How are operating leases reported in the lessee’s balance sheet?
Equipment to manufacture instructions : What are the consequences of not installing equipment to manufacture's instructions?
Weap to perform subtracting two complex numbers : (Complex Class) Create a class called Complex for performing arithmetic with complex numbers. Write a program to test your class.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

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