Wednesday, April 6, 2016

URI 1066 Solution in java language || Even, Odd, Positive and Negative



URI Online Judge | 1066

Even, Odd, Positive and Negative

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Make a program that reads five integer values. Count how many   of these values are even, odd, positive and negative. Print these information like following example.

Input

The input will be 5 integer values.

Output

Print a message like the following example with all letters in lowercase, indicating how many of these values ​​areeven, odd, positive and negative.
Input SampleOutput Sample
-5
0
-3
-4
12
3 valor(es) par(es)
2 valor(es) impar(es)
1 valor(es) positivo(s)
3 valor(es) negativo(s)

URI 1066 Solution in java language || Even, Odd, Positive and Negative:

  1. package URI_Problems_solution;

  2. import java.util.Scanner;

  3. public class URI_1066 {

  4. public static void main(String[] args) {
  5. int X, even = 0,odd = 0,positive = 0,negative = 0;
  6. Scanner input =new Scanner(System.in);
  7. for (int i = 1; i <= 5; i++) {
  8. X = input.nextInt();
  9. if (X % 2 == 0) {
  10. even += 1;
  11. }
  12. if (X % 2 != 0) {
  13. odd += 1;
  14. }
  15. if (X > 0) {
  16. positive += 1;
  17. }
  18. if (X < 0) {
  19. negative += 1;
  20. }
  21. }
  22. System.out.print(even+" valor(es) par(es)\n");
  23. System.out.print(odd+" valor(es) impar(es)\n");
  24. System.out.print(positive+" valor(es) positivo(s)\n");
  25. System.out.print(negative+" valor(es) negativo(s)\n");
  26. }

  27. }


No comments:
Write comments

To know more about the problem, give us your valuable commment. We'll try to help you. Thanks

All rights reserved ©2016 -URI ONLINE JUDGE SOLUTION | Developed by Maniruzzaman Akash

© 2016 URI ONLINE JUDGE SOLUTION. Developed by Maniruzzaman Akash | Distributed By Gooyaabi Templates
Powered by Blogger.