Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- public class Cassone {
- static double kmToMill(double km) {
- double mill = km * 1.6;
- return mill;
- }
- public static void main(String[] args) {
- try {
- RandomAccessFile fileKi = new RandomAccessFile("szamok.txt", "rw");
- Scanner bill = new Scanner(System.in);
- double osszes = 0;
- int db = 0;
- while (true) {
- double szam = bill.nextDouble();
- if(szam == -1)
- break;
- double mill = kmToMill(szam);
- osszes += mill;
- db++;
- System.out.println(mill + "\n");
- fileKi.writeBytes(mill + "\n");
- }
- System.out.println("átlag: " + osszes/db);
- fileKi.close();
- } catch(IOException e){
- System.err.println(e);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement