View Single Post
  #5 (permalink)  
Old 06-26-2008, 08:15 AM
janeansley's Avatar
janeansley janeansley is offline
Member
 
Join Date: Jun 2008
Posts: 23
janeansley is on a distinguished road
Code:
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.
Reply With Quote