URI Problem (Sequence of Numbers and Sum) 1101 Solution in Java

URI Problem (Sequence of Numbers and Sum) 1101 Solution in Java

URI Problem (Sequence of Numbers and Sum) 1101:
Sequence of Numbers and Sum 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
 * @Date : Oct 17, 2016
 * @Time : 8:00:38 PM
 */
public class Uri1101 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            int count = 0;

            if (x <= 0 || y <= 0) {
                break;
            }
            if (x > y) {
                int temp = x;
                x = y;
                y = temp;
            }
            for (int i = x; i <= y; i++) {
                count += i;
                System.out.print(i + " ");
            }
            System.out.println("Sum=" + count);
        }
    }
}
URI Problem (Sequence of Numbers and Sum) 1101 Solution in Java

URI Problem (Sum of Consecutive Odd Numbers II) 1099 Solution in Java

URI Problem (Sum of Consecutive Odd Numbers II) 1099:
Sum of Consecutive Odd Numbers II 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
 * @Date : Oct 17, 2016
 * @Time : 7:44:30 PM
 */
public class Uri1099 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            int count = 0;
            if (x > y) {
                int temp = x;
                x = y;
                y = temp;
            }
            for (int j = (x + 1); j < y; j++) {
                if (j % 2 != 0) {
                    count += j;
                }
            }
            System.out.println(count);
        }
    }
}
URI Problem (Sequence of Numbers and Sum) 1101 Solution in Java

URI Problem (Sequence IJ 4) 1098 Solution in Java

URI Problem (Sequence IJ 4) 1098:
Sequence IJ 4 is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.

import java.text.DecimalFormat;

/**
 * @E-mail : [email protected]
 * @Date : Oct 16, 2016
 * @Time : 11:28:50 PM
 */
public class Uri1098 {

    public static void main(String[] args) {
        for (double i = 0; i <= 2; i += 0.2) {
            System.out.println("I=" + go(toDouble(i)) + " J=" + go(toDouble(i + 1)));
            System.out.println("I=" + go(toDouble(i)) + " J=" + go(toDouble(i + 2)));
            System.out.println("I=" + go(toDouble(i)) + " J=" + go(toDouble(i + 3)));
        }
    }

    private static String go(double d) {
        if (d == (int) d) {
            return "" + (int) d;
        } else {
            return "" + d;
        }
    }

    private static double toDouble(double x) {
        DecimalFormat format = new DecimalFormat("#0.0");
        return Double.valueOf(format.format(x));
    }
}
URI Problem (Sequence of Numbers and Sum) 1101 Solution in Java

URI Problem (Sequence IJ 3) 1097 Solution in Java

URI Problem (Sequence IJ 3) 1097:
Sequence IJ 3 is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.

/**
 * @Author : Muhammad Harun-Or-Roshid
 * @E-mail : [email protected]
 * @Date : Oct 16, 2016
 * @Time : 11:24:10 PM
 */
public class Uri1097 {

    public static void main(String[] args) {
        int p = 7;
        for (int i = 1; i < 10; i += 2) {
            for (int j = p; j >= p-2; j--) {
                System.out.println("I=" + i + " J=" + j);
            }
            p+=2;
        }
    }
}
URI Problem (Sequence of Numbers and Sum) 1101 Solution in Java

URI Problem (Sequence IJ 2) 1096 Solution in Java

URI Problem (Sequence IJ 2) 1096:
Sequence IJ 2 is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.

/**
 * @Author : Muhammad Harun-Or-Roshid
 * @E-mail : [email protected]
 * @Date : Oct 16, 2016
 * @Time : 11:12:17 PM
 */
public class Uri1096 {

    public static void main(String[] args) {
        for (int i = 1; i < 10; i += 2) {
            for (int j = 7; j >= 5; j--) {
                System.out.println("I=" + i + " J=" + j);
            }
        }
    }
}
URI Problem (Sequence of Numbers and Sum) 1101 Solution in Java

URI Problem (Sequence IJ 1) 1095 Solution in Java

URI Problem (Sequence IJ 1) 1095:
Sequence IJ 1 is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.

/**
 * @Author : Muhammad Harun-Or-Roshid
 * @E-mail : [email protected]
 * @Date : Oct 16, 2016
 * @Time : 10:47:47 PM
 */
public class Uri1095 {

    public static void main(String[] args) {
        int i = 1;
        for (int j = 60; j >= 0; j-=5) {
            System.out.println("I="+i+" J="+j);
            i+=3;
        }
    }
}
URI Problem (Sequence of Numbers and Sum) 1101 Solution in Java

URI Problem (Experiments) 1094 Solution in Java

URI Problem (Experiments) 1094:
Experiments is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.

import java.text.DecimalFormat;
import java.util.Scanner;

/**
 * @Author : Muhammad Harun-Or-Roshid
 * @Date : Oct 15, 2016
 * @Time : 3:24:24 PM
 */
public class Uri1094 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String value;
        String values[];
        int n = sc.nextInt();
        int c = 0, r = 0, s = 0, total = 0;
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            String b = sc.next();
            if (a >= 1 && a <= 15) {
                if (b.equalsIgnoreCase("C")) {
                    c += a;
                }
                if (b.equalsIgnoreCase("R")) {
                    r += a;
                }
                if (b.equalsIgnoreCase("S")) {
                    s += a;
                }
                total += a;
            }
        }
        double c_c = toDouble((c / (double) total) * 100.00);
        double c_r = toDouble((r / (double) total) * 100.00);
        double c_s = toDouble((s / (double) total) * 100.00);

        System.out.println("Total: " + total + " cobaias");
        System.out.println("Total de coelhos: " + c);
        System.out.println("Total de ratos: " + r);
        System.out.println("Total de sapos: " + s);

        System.out.printf("Percentual de coelhos: %.2f %%\n", c_c);
        System.out.printf("Percentual de ratos: %.2f %%\n", c_r);
        System.out.printf("Percentual de sapos: %.2f %%\n", c_s);

    }

    private static double toDouble(double x) {
        DecimalFormat format = new DecimalFormat("#0.00");
        return Double.valueOf(format.format(x));
    }
}
URI Problem (Sequence of Numbers and Sum) 1101 Solution in Java

URI Problem (Highest and Position) 1080 Solution in Java

URI Problem (Highest and Position) 1080:
Highest and Position 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
 * @Date : Oct 15, 2016
 * @Time : 1:34:13 PM
 */
public class Uri1080 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int values[] = new int[100];
        int value = 0, index = 0;

        for (int i = 0; i < 100; i++) {
            values[i] = sc.nextInt();
            if (values[i] > value) {
                value = values[i];
                index = i;
            }
        }
        System.out.println(value);
        System.out.println((index + 1));

    }
}
URI Problem (Sequence of Numbers and Sum) 1101 Solution in Java

URI Problem (Weighted Averages) 1079 Solution in Java

URI Problem (Weighted Averages) 1079:
Weighted Averages is a basic problem on URI online judge for novice problem solver.
You can find details on this Link.

import java.text.DecimalFormat;
import java.util.Scanner;

/**
 * @Author : Muhammad Harun-Or-Roshid
 * @Date : Oct 15, 2016
 * @Time : 1:23:20 PM
 */
public class Uri1079 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = 2, b = 3, c = 5;
        for (int i = 0; i < n; i++) {
            double x = sc.nextDouble();
            double y = sc.nextDouble();
            double z = sc.nextDouble();
            System.out.println(toDouble(((x * a) + (y * b) + (z * c)) / (a + b + c)));
        }
    }

    private static double toDouble(double x) {
        DecimalFormat format = new DecimalFormat("#0.0");
        return Double.valueOf(format.format(x));
    }
}
URI Problem (Sequence of Numbers and Sum) 1101 Solution in Java

URI Problem (Multiplication Table) 1078 Solution in Java

URI Problem (Multiplication Table) 1078:
Multiplication Table 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
 * @Date : Oct 15, 2016
 * @Time : 1:16:50 PM
 */
public class Uri1078 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n > 1 && n < 1000) {
            for (int i = 1; i <= 10; i++) {
                System.out.println(i + " x " + n + " = " + (i * n));
            }
        }
    }
}
URI Problem (Sequence of Numbers and Sum) 1101 Solution in Java

URI Problem (Remaining 2) 1075 Solution in Java

URI Problem (Remaining 2) 1075:
Remaining 2 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
 * @Date : Oct 15, 2016
 * @Time : 1:08:11 PM
 */
public class Uri1075 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n < 10000) {
            for (int i = 1; i <= 10000; i++) {
                if (i % n == 2) {
                    System.out.println(i);
                }
            }
        }
    }
}
URI Problem (Sequence of Numbers and Sum) 1101 Solution in Java

URI Problem (Even or Odd) 1074 Solution in Java

URI Problem (Even or Odd) 1074:
Even or Odd 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
 * @Date : Oct 14, 2016
 * @Time : 10:47:52 PM
 */
public class Uri1074 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n < 10000) {
            for (int i = 0; i < n; i++) {
                int x = sc.nextInt();
                if (x > -10000000 && x < 10000000) {
                    if (x == 0) {
                        System.out.println("NULL");
                    } else if (x % 2 == 0) {
                        if (x > 0) {
                            System.out.println("EVEN POSITIVE");
                        } else {
                            System.out.println("EVEN NEGATIVE");
                        }
                    } else if (x > 0) {
                        System.out.println("ODD POSITIVE");
                    } else {
                        System.out.println("ODD NEGATIVE");
                    }
                }
            }
        }
    }
}
URI Problem (Sequence of Numbers and Sum) 1101 Solution in Java

URI Problem (Even Square) 1073 Solution in Java

URI Problem (Even Square) 1073:
Even Square 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
 * @Date : Oct 14, 2016
 * @Time : 10:37:29 PM
 */
public class Uri1073 {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n > 5 && n < 2000) {
            for (int i = 1; i <= n; i++) {
                if (i % 2 == 0) {
                    System.out.println(i + "^2" + " = " + (int)Math.pow(i, 2));
                }
            }
        }
    }
}
URI Problem (Sequence of Numbers and Sum) 1101 Solution in Java

URI Problem (Interval 2) 1072 Solution in Java

URI Problem (Interval 2) 1072:
Interval 2 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
 * @Date : Oct 14, 2016
 * @Time : 10:27:14 PM
 */
public class Uri1072 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int in = 0, out = 0;
        if (n < 10000) {
            for (int i = 0; i < n; i++) {
                int value = sc.nextInt();
                if (value > -10000000 && value < 10000000) {
                    if (value >= 10 && value <= 20) {
                        in++;
                    } else {
                        out++;
                    }
                }
            }
            System.out.println(in+" in");
            System.out.println(out+" out");
        }
    }
}
URI Problem (Sequence of Numbers and Sum) 1101 Solution in Java

URI Problem (Sum of Consecutive Odd Numbers I) 1071 Solution in Java

URI Problem (Sum of Consecutive Odd Numbers I) 1071:
Sum of Consecutive Odd Numbers I 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
 * @Date : Oct 14, 2016
 * @Time : 9:46:56 PM
 */
public class Uri1071 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x, y, total = 0;
        x = sc.nextInt();
        y = sc.nextInt();
        if (x > y) {
            int temp = x;
            x = y;
            y = temp;
        }
        for (int i = x + 1; i < y; i++) {
            if (i % 2 != 0) {
                total += i;
            }
        }
        System.out.println(total);
    }
}
URI Problem (Sequence of Numbers and Sum) 1101 Solution in Java

URI Problem (Six Odd Numbers) 1070 Solution in Java

URI Problem (Six Odd Numbers) 1070:
Six Odd Numbers 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
 * @Date : Oct 14, 2016
 * @Time : 9:36:31 PM
 */
public class Uri1070 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int count = 0;
        if (x > 0) {
            while (count < 6) {
                if (x % 2 != 0) {
                    count++;
                    System.out.println(x);
                }
                x++;
            }

        }
    }
}
URI Problem (Sequence of Numbers and Sum) 1101 Solution in Java

URI Problem (Odd Numbers) 1067 Solution in Java

URI Problem (Odd Numbers) 1067:
Odd Numbers 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
 * @Date : Oct 14, 2016
 * @Time : 9:30:14 PM
 */
public class Uri1067 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        if (x >= 1 && x <= 1000) {
            for (int i = 1; i <= x; i++) {
                if (i % 2 != 0) {
                    System.out.println(i);
                }
            }
        }
    }
}
URI Problem (Sequence of Numbers and Sum) 1101 Solution in Java

URI Problem (Even Between five Numbers) 1065 Solution in Java

URI Problem (Even Between five Numbers) 1065:
Even Between five Numbers 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
 * @Date   : Oct 14, 2016
 * @Time   : 9:17:28 PM
 */
public class Uri1065 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int values[] = new int[5];
        int count = 0;
        for (int i = 0; i < values.length; i++) {
            values[i] = sc.nextInt();
            if(values[i]%2==0){
                count++;
            }
        }
        System.out.println(count+" valores pares");
    }
}
URI Problem (Sequence of Numbers and Sum) 1101 Solution in Java

URI Problem (Even, Odd, Positive and Negative) 1066 Solution in Java

URI Problem (Even, Odd, Positive and Negative) 1066:
Even, Odd, Positive and Negative 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
 * @Date : Oct 14, 2016
 * @Time : 9:22:14 PM
 */
public class Uri1066 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int values[] = new int[5];
        int pos = 0, neg = 0, even = 0, odd = 0;
        for (int i = 0; i < values.length; i++) {
            values[i] = sc.nextInt();
            if (values[i] > 0) {
                pos++;
            }
            if (values[i] < 0) {
                neg++;
            }
            if (values[i] % 2 == 0) {
                even++;
            } else {
                odd++;
            }
        }
        System.out.println(even + " valor(es) par(es)");
        System.out.println(odd + " valor(es) impar(es)");
        System.out.println(pos + " valor(es) positivo(s)");
        System.out.println(neg + " valor(es) negativo(s)");

    }
}
URI Problem (Sequence of Numbers and Sum) 1101 Solution in Java

URI Problem (Positives and Average) 1064 Solution in Java

URI Problem (Positives and Average) 1064:
Positives and Average 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
 * @Date : Oct 14, 2016
 * @Time : 8:52:04 PM
 */
public class Uri1064 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double values[] = new double[6];
        int count = 0;
        double total = 0;
        for (int i = 0; i < values.length; i++) {
            values[i] = sc.nextDouble();
        }
        if (checkValue(values)) {
            for (int i = 0; i < values.length; i++) {
                if (values[i] > 0) {
                    count++;
                    total += values[i];
                }
            }

            if (count != 0) {
                System.out.println(count + " valores positivos");
                System.out.printf("%.1f\n", (total / count));
            }
        }
    }

    private static boolean checkValue(double x[]) {
        boolean flag = false;
        for (int i = 0; i < x.length; i++) {
            if (x[i] > 0) {
                flag = true;
                break;
            }
        }
        return flag;
    }
}