URI Problem (Selection Test 1) 1035 Solution in Java

Problem Solving, URI

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;
    }
}

0 Comments

You may find interest following article

Chapter 4 Relational Algebra

Relational Algebra The part of mathematics in which letters and other general symbols are used to represent numbers and quantities in formula and equations. Ex: (x + y) · z = (x · z) + (y · z). The main application of relational algebra is providing a theoretical foundation for relational databases, particularly query languages for such databases. Relational algebra...

Chapter 3 Components of the Database System Environment

Components of the Database System Environment There are five major components in the database system environment and their interrelationships are. Hardware Software Data Users Procedures Hardware:  The hardware is the actual computer system used for keeping and accessing the database. Conventional DBMS hardware consists of secondary storage devices, usually...