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

  Java class to accept a user-s hourly rate of pay

Write a class that accepts a user's hourly rate of pay and the number of hours worked. Display the user's gross pay, the withholding tax (15% of gross pay), and the net pay (gross pay - withholding).

  Define private instance variable to hold boolean value

Write a Java Enumeration "LetterGrade" that represents letter grades A through F including plus and minus grades. Define a private instance variable to hold a boolean value.

  Create a project in eclipse

Create a new project

  Write a java program called salesinfominer

Write a Java program called SalesInfoMiner that reads in a file of products, stored in text format. The program must then read in information about past sales transactions and output all the products to a new file, sorted by product description,..

  An api for a library that provides for all these operations

Quaternions can be represented with four (4) real numbers (a,b,c,d). They can be added, subtracted, multiplied and divided. You can multiply a quaternion by a scalar (which produces a quaternion as a result)

  Method named isallvowels that returns

Write a method named isAllVowels that returns whether a String consists entirely of vowels (a, e, i, o, or u, case-insensitively). If every character of the String is a vowel, your method should return true. If any character of the String is a non-vo..

  Write a program that asks a user for a file name and prints

Write a program that asks a user for a file name and prints the number of characters, words, and lines in that file.

  Class to initialize values

Create a constructor that allows a user of the class to initialize values. Also create a method named SetJustSold()(Hint ++) that increments the number of hot dogs the stand has sold by one and should also increase the TotalSold by one

  Design and implement a small and simple email server

Design and implement a small and simple email server using the concept of web based information system (WBIS).

  Class diagram represents the relationship between parents

Draw a class diagram that represents the relationship between parents, children, and grandparents. Take into account that a person can have both a parent and a child. Annotate associations with roles and multiplicities.

  A java program that will prompt the user to input a file

Write a Java program that will prompt the user to input a file (document) in order to count the frequency of each word. This program will display the frequency of each word sorted alphabetically or by frequency (depending on the preference of the use..

  You must also do the work of sorting

You must also do the work of sorting in the method. You cannot just call another library method. Use loops to show the data in the original array as well as the repopulated array in ascending order.

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