URI Problem 1035 Solution in Java

Problem Details Link

Solution:



import java.util.Scanner;

import java.util.Scanner;

/**
 * @Author : Muhammad Harun-Or-Roshid
 * @E-mail : md.parvez28@gmail.com
 * @Date : Oct 10, 2016
 * @Time : 12:41:48 AM
 */
public class Uri1035 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a, b, c, d;
        a = sc.nextInt();
        b = sc.nextInt();
        c = sc.nextInt();
        d = sc.nextInt();
        if (compareTo(b, c) && compareTo(d, a) && compareTo(sum(c, d), sum(a, b))
                && checkPositive(c) && checkPositive(d) && checkEven(a)) {
            System.out.println("Valores aceitos");
        } else {
            System.out.println("Valores nao aceitos");
        }
    }

    /**
     *
     * @param x given value
     * @param y compare value
     * @return true or false
     */
    private static boolean compareTo(int x, int y) {
        return x > y;
    }

    /**
     *
     * @param x
     * @param y
     * @return sum of x and y
     */
    private static int sum(int x, int y) {
        return x + y;
    }

    /**
     *
     * @param x check positive value
     * @return true or false
     */
    private static boolean checkPositive(int x) {
        return x > 0;
    }

    /**
     *
     * @param x check even
     * @return true or false
     */
    private static boolean checkEven(int x) {
        return x % 2 == 0;
    }
}

Comments

Popular posts from this blog

URI Problem 1094 Solution in Java

URI Problem 1099 Solution in Java

URI Problem 1012 Solution in Java