Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class Loop1 {
- public static void main(String[] args) {
- int num = 0;
- int oddCounter = 0;
- Scanner s = new Scanner(System.in);
- for (int i = 1; i <= 10; i += 1) {
- System.out.println("Please enter a number: ");
- num = s.nextInt();
- if (num % 2 != 0) {
- oddCounter += 1;
- }
- }
- System.out.println("The total number of odd numbers you typed is " + oddCounter);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement