URI Problem (Selection Test 1) 1035:
Selection Test 1 is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.
import java.util.Scanner; /** * @Author : Muhammad Harun-Or-Roshid * @E-mail : [email protected] * @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 <i>check even</i> * @return true or false */ private static boolean checkEven(int x) { return x % 2 == 0; } }