import java.util.Scanner;
import java.io.*;
public class TestCalculate
{
public static void main( String args[] )
throws java.io.IOException
{
final double PCOUNT = infinity;
double a[]= new double[PCOUNT];
double i, y=0;
String filename, inLine;
//keyboard input stream
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
//get the input data
System.out.print( "Enter the txt file name: " );
filename = br.readLine();
//file input stream
BufferedReader fi = new BufferedReader(new FileReader(filename));
//read existing data and calculate
for(i=0; i++)
{
inLine = fi.readLine();
a[i] = Double.parseDouble(inLine);
y = ((4.2*a[i]/1010)-1.35);
}
fi.close();
//store the calculated value in another txt file
PrintWrite pw = new PrinWriter(new BufferedWriter(new FileWriter(filename)));
for(i=0; i++)
pw.println(y[i]);
System.out.print( "A calculated Output.txt file is created" );
pw.close();
}
}
I have tried to create something here, I am not sure is correct as I am new still learning, but my program having errors. I have problem with the calculation and create the "Output.txt". Please correct me. Thanks.