I wrote a simple Java program that is supposed to calculate the radius of a circle if the area is given. My program is returning the wrong value for radius and I was wondering if anyone could show me my error.
Thanks,
Big Dave
Thanks,
Big Dave
Code:
import java.io.*;
import java.text.*;
import java.lang.Math;
class Radius
{
public static void main (String args[])
{
FileOutputStream fout;
try
{
fout = new FileOutputStream ("radius.csv");
double area;
System.out.println("Enter the area value");
area = System.in.read();
double radius = (Math.sqrt( area / Math.PI));
System.out.println("The radius is: ");
System.out.println( radius );
new PrintStream(fout).print("The radius is: ");
new PrintStream(fout).println( radius);
}
catch (IOException e)
{
System.err.println ("Unable to write to file");
System.exit(-1);
}
}
}