Created
January 17, 2020 14:14
-
-
Save mamiwinsfall93/e5267413f4d1d1cf82df8e1ac4e4cf3e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Positive number | |
Use the keyboard to enter three integers. Display the number of positive numbers in the original set. | |
*/ | |
import java.io.*; | |
import java.util.Scanner; | |
public class Solution { | |
public static void main(String[] args) throws Exception { | |
Scanner sc = new Scanner(System.in); | |
int[] a = new int[3]; | |
a[0] = sc.nextInt(); | |
a[1] = sc.nextInt(); | |
a[2] = sc.nextInt(); | |
int count = 0; | |
for (int i = 0; i < 3; i++) { | |
if (a[i] > 0) { | |
count ++; | |
} | |
} | |
System.out.println(count); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Clean, simple but quite enough to solve the problem. Thanks for sharing :)