CSES - Putka Open 2015 – 1/6 - Results
Submission details
Task:Jakkara
Sender:
Submission time:2015-07-19 15:52:51 +0300
Language:Java
Status:COMPILE ERROR

Compiler report

input/jalka.java:3: error: class Jalka is public, should be declared in a file named Jalka.java
public class Jalka {
       ^
1 error

Code

import java.util.Scanner;

public class Jalka {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        

        int a, b, c, d = 0;
        
        a = input.nextInt();
        b = input.nextInt();
        c = input.nextInt();
        d = input.nextInt();
        
        int keski = (a + b + c + d) / 4;
        
        int energia = 0;
        
        energia += energiaa(a, keski);
        energia += energiaa(b, keski);
        energia += energiaa(c, keski);
        energia += energiaa(d, keski);
        
        System.out.println(energia);
    }
    
    public static int energiaa(int jalka, int keski) {
        if (jalka > keski) {
            return jalka - keski;
        } else {
            return jalka + keski;
        }
    }
    
}