Advertisement
NB52053

Olympics আইরিন vrsn

Aug 12th, 2017
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.98 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.FileNotFoundException;
  3. import java.io.FileReader;
  4. import java.io.IOException;
  5. import java.io.PrintWriter;
  6.  
  7. public class TestIO {
  8.    
  9.     public static void main(String[] args){
  10.         try {
  11.             FileReader fr = new FileReader("olympic.txt");
  12.             BufferedReader br = new BufferedReader(fr);
  13.             PrintWriter pw = new PrintWriter("processed.txt");
  14.             String s =br.readLine();
  15.            
  16.            
  17.             int value=0;
  18.            
  19.            
  20.             while(s!=null){
  21.                 String[] array = s.split(" ");
  22.                
  23.                
  24.                 for(int i=1;i<=3;i++){
  25.                      value+= Integer.parseInt(array[i]);
  26.                     System.out.println("Total value is : "+value);
  27.                 }
  28.                
  29.                 pw.println(s+"     "+"Total :"+value);
  30.                 value =0;
  31.                 System.out.println(s);
  32.                 s =br.readLine();
  33.             }
  34.            
  35.            
  36.            
  37.             fr.close();
  38.             pw.close();
  39.         } catch (FileNotFoundException e) {
  40.            
  41.             e.printStackTrace();
  42.         } catch (IOException e) {
  43.             // TODO Auto-generated catch block
  44.             e.printStackTrace();
  45.         }
  46.        
  47.     }
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement