Write a program that takes in four positive integers and outputs the number of odd numbers. (Hint: use the modulo operator to determine if a number is odd) Ex: If the input is: 1 2 3 4 the output is: 2 Ex: If the input is: 19 19 19 19 the output is: 4 3.46.1: zyLAB: Count odd numbers LabProgram.java import java.util.Scanner; public class LabProgram { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); /* Type your code here. */ } }
Added by Jose Luis P.
Close
Step 1
We can use the Scanner class in Java to take user input. Show more…
Show all steps
Your feedback will help us improve your experience
Akash M and 71 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
write a program in java to input values from user till the time an even number not entered and then find the sum of all odd values
Supreeta N.
Write a program to input a number and count the number of digits. The program further checks whether the number contains an odd number of digits or even number and displays the output accordingly. Sample input: 749 Sample output: Number of digits = 3. The number contains an odd number of digits.
Liam H.
Write a program to enter a number. If the number is a positive even, display three succeeding even numbers. If the number is a negative odd, display three preceding odd numbers. Otherwise, display the message 'Number is neither a positive even nor a negative odd.' Sample Input: -21 Sample Output: -23, -25, -27 Sample Input: 34 Sample Output: 36, 38, 40
Sophia F.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
Watch the video solution with this free unlock.
EMAIL
PASSWORD