View Code of Problem 118

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int count=1;
        while (scanner.hasNext()) {
            int N = scanner.nextInt();
            double res=5;
            if (N > 0 && N < 3) {
                System.out.println("Case #"+count+": "+5);
                count++;
            }else if((N-3)%2==0){
                res = res + (N - 3) * 1.5;
                System.out.println("Case #"+count+": "+String.format("%.0f",res));
                count++;
            }else{
                res = res + (N - 3) * 1.5+0.5;
                System.out.println("Case #"+count+": "+String.format("%.0f",res));
                count++;
            }

        }
    }
}

Double click to view unformatted code.


Back to problem 118