Hi guys, I have a text file that contains the amounts on the substrings (34, 47) of each line. I
All values must be added at the end of the file. I have this code that I started to start but I do not know how to proceed from here: The output is as follows: The amount is two In decimal places and I need a result in two decimal places too. What is the best way to achieve this? You can change your code to:
1.44576457E4 2.33434354E6 4.56875685 E3
decimalfile is the best option to use:
double round two docurium (double D) {Decimal two defaults = new decimals ("###"); Return double.Whoff (two format formats (D)); }
Public static zero main (string [] args) FileNotFoundException throws, IOException {// TODO code App logic here double yoga = 0.0; FileInputStream FS = New File InStस्ट ("C: / Analysis / RLL 4004.TXT"); BufferedReader br = new BufferedReader (new InputStreamReader (fs)); String line; While ((line = br.readline ())! = Null {string num = line.substring (34, 47); Double i = double. Prsd double (number); Sum = sum + i; Decimalable two defaults = new decimals ("###); Println (Double.valueOf (twoDForm.format (i))); } System.out.println ("SUM =" + Double.valueOf (twoDForm.format (sum))); }}
Comments
Post a Comment