+ 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) ; } }
2 Answers
+ 2
What's the error ?
+ 1
There are basically no syntax errors in this code. In terms of logic please let us know what you want to implement?