View Single Post
Old 07-17-2009, 03:34 PM   #12 (permalink)
pinki
Junior Member
 
Join Date: Feb 2007
Posts: 26
pinki is on a distinguished road
Default Java Program

Hi Chris,
Thank you so much for the help. I wrote a java program that would perform all the operations but using double precision variables. I know thats not what you wanted.

I read that quad precision is not supported by the JVM.

How did you get it work till the 90th decimal place?

Any further hints for me to start off....

here is the program.

import java.io.*;

public class Numbers
{
public static void main(String args[])
{
InputStreamReader isstream = new InputStreamReader(System.in);
BufferedReader buffRead = new BufferedReader(isstream);

try
{
System.out.println("Enter the first number:");
String a = buffRead.readLine();


System.out.println("Enter the second number:");
String b = buffRead.readLine();

double x = Double.parseDouble(a);
double y = Double.parseDouble(b);


double sum = x+y; //Addition of two numbers 9,2
System.out.println("Addition:"+' '+ sum);

double sub = x-y; //Subtraction of two numbers 9,2
System.out.println("Subtraction:"+' '+ sub);

double mul = x*y; //Multiplication of two numbers 9,2
System.out.println("Multiplication:"+' '+ mul);

double div = x/y; //Division of two numbers 9,2
System.out.println("Division:"+' '+ div);

double pow = Math.pow(x, y); // Power operation
System.out.println("Power Operation:"+' '+ pow);


}

catch (IOException e1) {
System.out.println("Error reading line");
}
catch(NumberFormatException e1) {
System.out.println("Error Converting Number");
}
}
}
pinki is offline   Reply With Quote