Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package cialem;
- import java.util.*;
- import java.io.*;
- public class Autobus {
- public static void main(String[] args) throws FileNotFoundException {
- /*
- Pobierz z pliku 'a.txt' 10 liczb, dodaj do kazdej liczby z pliku 'b.txt',
- a nastepnie zapisz wyniki w pliku 'c.txt'
- sume wszystkich zapisanych liczb napisz w konsoli
- */
- Scanner s1 = new Scanner(new File("a.txt"));
- Scanner s2 = new Scanner(new File("b.txt"));
- PrintStream pc = new PrintStream("c.txt");
- int a,b,c,suma=0;
- for(int i=0;i<10;i++)
- {
- c=0;
- /*
- String l1 = s1.nextLine();
- String l2 = s2.nextLine();
- a=Integer.parseInt(l1);
- b=Integer.parseInt(l2);
- */
- /*
- a = s1.nextInt();
- b = s2.nextInt();
- c=a+b;
- */
- c = s1.nextInt() + s2.nextInt();
- pc.println(c);
- suma=suma+c;
- }
- System.out.println(suma);
- s1.close();
- s2.close();
- pc.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement