Pls provide a java program to develope a Rational number class?
I need a java program to develop a Rational number class , use JavaDoc comments for documentation and the implementation should use efficient representation for a rational number.ie (500/1000) should be represented as (1/2).
Comments
//Declare variables
Scanner scan = new Scanner(System.in);
int i,j;
//Get fraction from user
System.out.println("Enter numberator:");
i = scan.nextInt();
System.out.println("Enter denomonator:");
j = scan.nextInt();
//Perform computation
int k = i % j;
if (k != 0) {
System.out.println("Reduced is: " + k / i + "/" + j / k);
} else {
System.out.println(i/j);
}
}
Here is the basic structure, you need to add code to make sure its an int that is entered not a string or double or zero.
Many of us that answer questions are professional programmers and according to the secret programmer code of brotherhood we are not allowed to just give code to people trying to do homework. We would have to charge for the code.
However we can assist you with making YOUR code work if you are having a problem. Make sure you post the code that you have and describe any problems that you cannot figure out.
a million. Integer = is an total quantity. e.g int = 2; choose the flow = is a decimal quantity, extremely like a double yet is more beneficial precise e.g. choose the flow/double = 2.4; 2. certain/No, that is not always the case that is needed to position in writing as them to be the first 2 lines, as you may declare a consistent earlier putting forward the important approach. e.g public type FILENAME { static very last int TERMINATOR = -999 public static void important(String [] args) }//type that is likewise no longer needed for to have a important approach as in non-purposes instructions that is not needed