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

  Explaining binary normalization shift-and-subtract

Convert input arguments to binary. Binary normalization shift-and-subtract.

  Prove by induction of recurrence relation has solution

Describe why Kim's recurrence relation is correct. Prove by induction that Kim's recurrence relation has solution: M(k) = 3^(k - 1).

  Probability of heavy- normal and light snowfalls

Brenda evaluates the probability of heavy, normal, and light snowfalls as 0.25, 0.6, and 0.15, respectively. So what must be size of the order you would suggest to Brenda? Justify why.

  Explain reinforcement of changing program standards

Use operant conditioning, with the program of shaping, to get sloppy roommate to make bed neatly. Incorporate and label antecedent stimulus.

  Case of healthy people pharmacy

Consider the case of Healthy People Pharmacy. Healthy People Pharmacy is a small town pharmacy that not only sells pharmaceuticals but also sells items ranging from milk to socks

  Ways to avoid communication pitfalls

Based on the section on "Watch out for communication pitfalls" in the Bateman and Snell text, describe some ways that Lei could have avoided this situation.

  Evaluate for risk management purposes

Choose three information assets that a typical organization has and evaluate for risk management purposes which vulnerability should be evaluated for additional controls first?

  Computing requirements for dozen handbags

Leather-goods factory manufactures ?ve styles of handbags, whose variable contributions are $30, $40, $45, $25, and $60 per dozen, respectively.

  Express statements using quantifiers and logical connectives

Express each of these statements using quantifiers, logical connectives, and the predicates P(x), Q(x), R(x) and S(x). Does the fourth item follow from the first three taken together?

  Feature set of free helix forensics cd

Visit Helix web site and read about feature set of free Helix forensics CD. Note that documentation for Helix is not on CD, to keep it down to ~700MB.

  Class polygon which draws a hexagon for a set of numbers

Write a class Polygon which draws a hexagon for a set of numbers given by the user. You must only use method drawLine of class Graphics (other fill or draw methods won't be accepted).

  Features of organization to make and use information systems

Write down the features of organizations do managers require to know about to make and use information systems successfully?

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