QuestionQuestion

Write a Java program that first asks the user how many numbers will be entered - let's call this positive integer n. Then the program takes input n integers (not ordered) and outputs how many even values and how many odd values have been entered. Input control: the input should be restricted to only integers between 0 and 100.

SAMPLE OUTPUT:
How many numbers in input? 10
Now enter 10 integers:
123
ERROR! Valid range 0 - 100. REENTER: 1
2
3
129
ERROR! Valid range 0 - 100. REENTER: 4
5
6
7
176
ERROR! Valid range 0 - 100. REENTER: 8
9
10
You entered 5 odd numbers and 5 even numbers.

Using while loops, for loops, and if and else statements.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

import java.util.Scanner;

public class EvenOdd {

public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
int[] nums;
int count, even = 0, odd = 0;

System.out.print("How many numbers in input? ");
count = input.nextInt();
nums = new int[count];
System.out.println("Now enter " + count + " integers: ");
for(int i = 1; i <= count; i++)
{
nums[i-1] = input.nextInt();...
$10.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats