Create a rational number class

Assignment Help Basic Computer Science
Reference no: EM13220051

Create a Rational Number class. A Rational number has 2 parts, an integer numerator and an integer denominator. Add two constructors (negative denominators must be moved to the numerator), getters, setters, a print method, and an input method. Data should print as numerator/denominator. Data can be read in as two integer values separated by a space. Add methods, using overloaded operators, for addition, subtraction, multiplication, division. Code friend methods to do equality, less than relationship test, and output (overload the << operator). Code a main method to test all the class and friend methods. Be sure to test relationship methods for both true and false. Run 3 times with 2/3 and ½ ½ and 16/32 3/-5 and 2/1. Rational Operations: a/b + c/d = (a*d + b*c) / (b*d) a/b - c/d = (a*d -b*c) / (b*d) (a/b) * (c/d) = (a*c) / (b*d) (a/b) / (c/d) = (a*d) / (c*b) (a/b) = = (c/d) means (a*d) = = (c*b) (a/b) < (c/d) means (a*d) < (c*b)

Reference no: EM13220051

Questions Cloud

Explain traces of iron and titanium : traces of iron and titanium. If the sapphire were found to contain 0.155 g of oxygen, what is the mass of the gemstone?
Is buying a new car your best option : Economic considerations, including ROI, risks, cost benefits (tangible and intangible), and net present value (NPV) for the next 5 years Organizational factors, in this instance, you and your business needs for the car.
How would a substancial appreciation in the european euro : how would a substancial appreciation in the european euro in the foreign exchange market affect the quantity of imports of European products by the US How would such an appreciation of the European euro affect travel by Americans to Europe
Human resource departments responding to challenge of shrm : What are the main strategic reward options available to organization and why are reward systems potentially a problem for SHRM and what are the main ways that SHRM can integrate reward within SHRM?
Create a rational number class : Create a Rational Number class. A Rational number has 2 parts, an integer numerator and an integer denominator. Add two constructors (negative denominators must be moved to the numerator), getters, setters, a print method, and an input method.
Explain substance must evaporate to freeze : What mass (in grams) of this substance must evaporate to freeze 200g of water initially at 15 degrees C? (The heat of fusion of water is 334 J/g; the specific heat of water is 4.18 J/g-K.)
Write a class that maintains the top 10 scores : but use a singly linked list instead of an array Part 2: Implement the stack and queue with a single class interfaces with a unique class that is derived from class LinkedDeque (Code Fragment 5.21)
Write a program that accepts a temperature : Write a program that accepts a temperature in Fahrenheit from a user and converts it to Celsius by subtracting 32 from the Fahrenheit value and multiplying the result by 5/9. Display both values. Save the class as FahrenheitToCelsius.java.
Explain what is the molecular formular of phosphorus : the mass density of phosphorus vapour is 0.6388 kg per meter cube. What is the molecular formular of phosphorus under these conditions

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Provide explanation for why tablespace might have problem

Provide explanation for why your tablespace might have problem, and write at least two actions you can take to lessen the problem

  Fork function

Create a C program that takes an integer argument from the command line and outputs sum of all digits of the integer. For example, the result of the invocation sum of digits 12345 should be fifteen.

  Shortest path between each pair of nodes using floyd''s metho

find the shortest path between each pair of nodes using Floyd's method

  Investigate project management body of knowledge

Investigate Project Management Body of Knowledge (PMBoK). Write a report on one of knowledge areas. Describe the task of understanding potential threats

  How much of program-s time slice can be spent waiting

Desired data to rotate around to the read/write head, how much of a program's time slice can be spent waiting for a read operation from a disk to take place?

  Address the use of software repositories from fedora

Include only those repositories that are used by default in Fedora. Cite the resources that you used for writing this paper in the Chicago Manual of Style format.

  Discuss what makes a successful information security

Discuss what makes a successful information security awareness program and how a security awareness program can be one of an organization's most powerful protection strategies.

  Advantages and disadvantages of asymmetric or symmetric key

The Institute has collaborated with XYZ inc. for research on genetics. Information should be kept top secret at any cost. At ABC Institute, researchers are not sure about kind of key.

  What is server side and client side scripting

Describe and explain 5 underlying concepts that drive interaction design. Please include appropriate details and examples with applicable references in APA style.

  Four techniques for analyzing

Briefly compare and contrast the four techniques for analyzing the costs and benefits of a proposed system. What do you see as particular strengths and weakness of each method?

  Design an algorithm in pseudocode to solve

Design an algorithm in pseudocode to solve this problem. Make sure to include steps to get each input and generate each output

  Find a regular expression for the language

Find a regular expression for the language over {a,b} that consists of all strings containing exactly one occurrence of substring ab.

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