+ 1

Design an program to input 5 integers repeatedly and determine the number of odd integers given by the user. is this correct?

import java.util.*; import java.util.Scanner; public class OddInt { public static void main (String[] args) { // TODO: Add your code here Scanner scanner = new Scanner(System.in) ; System.out.print("\n\nPls type 5 integers:") ; int ex, hate, you = 0; for (ex = 1; ex <=5; ex++ ) { hate = scanner.nextInt() ; if (hate%2==1) { you++ ; } } System.out.print("The total number of odd integer = " + you) ; } }

20th Apr 2021, 11:23 AM
Wilsonzkie Ong
Wilsonzkie Ong - avatar
2 Answers
+ 2
What's the error ?
20th Apr 2021, 11:25 AM
Soumik
Soumik - avatar
+ 1
There are basically no syntax errors in this code. In terms of logic please let us know what you want to implement?
20th Apr 2021, 11:27 AM
Atul [Inactive]