Define a fraction adt to represent and store rational number

Assignment Help Basic Computer Science
Reference no: EM131312960

Python provides a numeric class for working with floating-point values. But not all real numbers can be represented precisely on a computer since they are stored as binary values. In applications where the precision of real numbers is important, we can use rational numbers or fractions to store exact values. A fraction, such as , consists of two parts, both of which are integers. The top value, which can be any integer value, is known as the numerator. The bottom value, which must be greater than zero, is known as the denominator.

(a) Define a Fraction ADT to represent and store rational numbers. The ADT should include all of the common mathematical and logical operations. In addition, your ADT should provide for the conversion between floatingpoint values and fractions and the ability to produce a string version of the fraction.

(b) Provide a Python implementation of your Fraction ADT.

Reference no: EM131312960

Questions Cloud

Discuss the sustainability of the fossil fuel industry : Write a short review of an environmental law. Explicitly introduce the major provisions in the law. Discuss the sustainability of the fossil fuel industry and the problem of their use as we move into the future.
Briefly describe how your machine works : Describe a TM that solves the acceptance problem. Provide a brief but complete English description of how the machine works.
Assignment on conflict resolution : Conflict resolution is a necessary skill for any manager or leader. In this assignment, you will examine the difference between conflict and competition. You will also explore ways of determining when conflict resolution is necessary and explain w..
Applying concepts you learned in the required readings : Research a company that has moved some of its operations overseas. Discuss how this has directly affected the American workforce.  Applying concepts you learned in the required readings, discuss who has benefited more from this practice: the Unite..
Define a fraction adt to represent and store rational number : The ADT should include all of the common mathematical and logical operations. In addition, your ADT should provide for the conversion between floatingpoint values and fractions and the ability to produce a string version of the fraction.
Develop healthy-city initiative suitable for implementation : Develop a 4 page healthy-city initiative suitable for implementation by your city. What kinds of disasters, both natural and man-made, are most likely to occur in your area?
Graph the yield to maturity against the time to maturity : Graph the yield to maturity against the time to maturity.-  Is this yield curve consistent with any of the yield curve theories? Explain.
Skills that public personnel managers : Predict two (2) trends that are likely to impact public service in the future. Next, choose two (2) skills that public personnel managers may seek in response to these trends. Provide a rationale and support your position with appropriate academic..
Creates a new empty activities calendar initialized : addActivity( date, activity ): Adds the given activity description to the calendar for the given date. The date must be within the valid date range for the calendar.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Summary of a discrete area of knowledge

A review article, a summary of a discrete area of knowledge, scope ranging from very to mildly narrow, peer-reviewed, rarely containing methods and materials, often contains depictions of experimental results.

  What are the contextual and behavioral attributes

How is the relationship among objects modeled in collective outlier detection?

  Partitioning algorithm and provide pseudocode

Develop this idea into a partitioning algorithm and provide pseudocode. Make sureyour algorithm is in-place (i.e., do not use more than a constant amount of extra space).

  Duplicate elements from an array list of integers

Write a method that removes the duplicate elements from an array list of integers using the following header:

  Why is bit order then not relevant to presentation

[Pos81] defines (in its Appendix B) the standard network bit order. Why is bit order then not relevant to presentation formatting?

  Backup domain controller in an existing domain

You install Windows NT Server on a computer, making the computer a backup domain controller in an existing domain. After installation, you discover that you used the wrong domain name. What should you do?

  Draw a use case model for the information system

The questions should aim to help you identify further details about the environment, the problem area and/or how the system would operate to help solve the problem

  Foreign direct investment in china

Please read "Country Focus: Foreign Direct Investment in China" (on page 247 in 7th edition and on page 223 in 8th edition). In the late 1970s, China opened its doors to foreign investors. By the mid 2000s, China attracted $65-70 billion of FDI an..

  How much electric power would be produced by these falls

Water flows over a waterfall, which is 120 m high, at a rate of 1.30E+6 kg/s. If half the potential energy of this water were converted into electric energy, how much electric power would be produced by these falls?

  How would you insert a section break in a document

How would you insert a section break in a document? You send a report to your boss for feedback, and it's returned to you with the edits noted in the electronic file. This Word feature is called.

  Find the power required to drive the compressor

Potential energy change and heat exchange with the environment are negligible. Determine the power required to drive the compressor

  Challenges of securing information

Create a 7-10-slide PowerPoint Presentation on the challenges of securing information, and list some of today's information security attacks. You may use various sources (scholarly).

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