Write a class called rationalnumber

Assignment Help JAVA Programming
Reference no: EM13166163

Write a class called RationalNumber that represents a fraction with an integer numerator and denominator. A RationalNumber object should hvae 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()

Return this rational number's denominator value; for examples, 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), return 3.

 

public String toString()

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

 

 

Reference no: EM13166163

Questions Cloud

Write a code fragment that would printout the multiplication : Write a code fragment that would printout the multiplication table for the number 3 multiplied by (1-10) .
Limiting reagent to calculate the theoretical yield : The theoretical yeild of Ni(NH3)6Cl2 moles must be calculated as well as the theoretical yield of Ni(NH3)6Cl2 grams. How do you find the limiting reagent to calculate the theoretical yield.
Why are the rates of diffusion of carbon monoxide : why are the rates of diffusion of carbon monoxide and nitrogen gas are virtually identical at the same temperature?
How many protons and neutrons are present in the plutonium : The best means of personal protection from radiation for emergency responders is the implementation of three basic principles: time, distance and shielding. Please show your work when answering the following questions.
Write a class called rationalnumber : Write a class called RationalNumber that represents a fraction with an integer numerator and denominator.
Develop written policies and procedures : Develop written policies and procedures to serve as standards of performance of the internal audit function and have the internal audit charter approved by both management and the board of directors.
Converts the temperature f in farenheit to c in celsius : Write a program that converts the temperature F in Farenheit to C in Celsius using C = (F-32)*5/9. For ease of programming you can display the result in fractions.
Hemispheric specialization than a paralegal : An office worker's personal differences may specialization in right and left hemispheres and are related to occupational success? For example, might a designer who relies on spatial skills have a different pattern of hemispheric specialization than a..
Propose stepwise sythesis starting from benzene : Propose stepwise sythesis of 2-cholor-4-nitrobenzoic acid starting from benzene

Reviews

Write a Review

JAVA Programming Questions & Answers

  To translate infix mathematical expression

Write a program in java to translate infix mathematical expression into postfix expression and a program to evaluate the postfix expression

  Java program to decide whether integer is perfect number

For example, 6 is a perfect number because 6 = 1 + 2 + 3. Write a Java program that decides whether integer is a perfect number.

  Fixing errors in a java program

You coded the following on line ten of the class MyApplet.java:

  Explain java-oriented microprocessors presented by sun

Research the latest Java-oriented microprocessors presented by Sun. In what ways are they optimized to implement Java programs?

  What is overloading and what is overriding

What is overloading and what is overriding? Wrtie JAVA code code to explain it.

  Java threads

This is an introductory assignment on Java synchronization. You will use Java Threads while learning more about concurrency and achieving atomicity using Java’s inbuilt mechanisms.

  Sets a loop to find 10 random generated

Write a java code that 1) uploads a file 2) sets a loop to find 10 random generated words from the file and then search those words by a. IndexSequential Method b. indexBinary Method. then, report how much time both methods took.

  It should have an if statement

The following are hints given: It should have an if statement. This add method determines what number greater than or less than the other number, than it adds the positive or negative. I think this should be a private method.

  Sequence of method in vector class

Construct a Vector class implementing a number of vector operations as methods along with a testing program to verify the class is working.

  Understand actual communication with an smtp server

Understand actual communication with an SMTP server can be achieved using TCP Sockets and understand the development of a graphical user interface (GUI) and use of event handling.

  How does a client send a string ti the server using udp

How does a client send a string ti the server using UDP? Show what the client would do to get data from some string, and create a datagram packet destined for a server at "www.google.com", port 12345.

  Instance methods

instance methods: setWidth(double w), setHeight(double h), double getWidth(), double getHeight() and double getArea() * A triangle's area is calculated by width*height*0.5  * all variables are private and methods public.

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