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

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

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