Constructs a new rational number to represent the ratio

Assignment Help Basic Computer Science
Reference no: EM131413068

Write a class called RationalNumber that represents a fraction with an integer numerator and denominator. A RationalNumber object should have the following methods:
public RationalNumber(int numerator, int denominator)

Constructs a new rational number to represent the ratio (numerator/denominator). The denominator cannot be 0, so throw an IllegalArgumentException if 0 is passed.
public RationalNumber()

Constructs a new rational number to represent the ratio (0/1).
public int getDenominator()

Returns this rational number's denominator value; for example, if the ratio is (3/5), returns 5.
public int getNumerator() Returns this rational number's numerator value; for example, if the ratio is (3/5), returns 3. public String toString()

Returns a String representation of this rational number, such as "3/5". You may wish to omit denominators of 1, returning "4" instead of "4/1".

An extra challenge would be to maintain your RationalNumber objects in reduced form, avoiding rational numbers such as 3/6 in favor of 1/2, or avoiding 2/-3 in favor of -2/3. Another possible extra feature would be methods to add, subtract, multiply, and divide two rational numbers.

Reference no: EM131413068

Questions Cloud

Difference between master data and transaction data : Integrated Enterprise Systems - IT 402 - Explain the difference between master data and transaction data in an enterprise system and how are they related. Support your answer with examples.
What is the output of the following sequence of loops : What is the output of the following sequence of loops? Notice that the code is the same as that in the previous exercise, except that the placement of the braces has changed.
Find the variances for both revenue and expenditures sides : Find the variances for both the revenue and expenditures sides and then discuss two to three problematic areas for the agency. Provide the results of the variances in a table (Excel or Word).
Describe the process of strategy mapping : Explain the process of strategy mapping and how it relates to performance management and establishing value propositions.
Constructs a new rational number to represent the ratio : Write a class called RationalNumber that represents a fraction with an integer numerator and denominator. A RationalNumber object should have the following methods:
Discuss about the imaginative futurism : Imaginative futurism in science fiction novels has a tendency to begin as predictions of technologies that are not yet realized. In this assessment, you are to research a technology or scientific plot device that originated in science fiction and ..
Identify three objectives for improving organizations growth : Identify at least three objectives for improving the organization's learning and growth, and show how they relate to the mission, vision and strategy of the organization.
How do you examine every key (or every value) of a map : It doesn't even have an iterator method like a Set does, nor can you use a for-each loop on it directly. How do you examine every key (or every value) of a Map?
Identify one specific example of a measure of learning : For your first posting in this Discussion, identify one specific example of a measure of learning and growth measure that you feel could be critical to an organization, but difficult to measure.

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