Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package myApp;
- import java.util.Scanner;
- public class class03_02 {
- public static void main(String[] args) {
- //init vars
- int n = 0,
- count = 0;
- //usage msg
- System.out.println("Type 10 numbers, seperated by Enter: ");
- //open in_stream
- Scanner s = new Scanner(System.in);
- //loop 10 times
- for (int i=0; i<10; i++) {
- n = s.nextInt(); //parse int
- if (n%2 == 1) { count += 1; } //if number is not-even, raise counter by 1
- }
- //close in_stream
- s.close();
- //output to user
- System.out.printf("# of unEven = %d%n", count);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment