Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java please Write a Java program which performs the following: Asks the user how

ID: 3694178 • Letter: J

Question

Java please

Write a Java program which performs the following: Asks the user how many number you want to enter (positive number less than 10). Creates an array of the appropriate size to hold all of the numbers. Asks the user to enter the numbers one by one. Prints all the numbers in the array using the separator " | " Prints all the even numbers in the array. Typical run of the program: How many numbers do you want to enter: (1-10) 6 enter number 1: 11 enter number 2: 2 enter number 3: 54 enter number 4: 6 enter number 5: 7 enter number 6: 98 This is the content of the array: 11 | 2 | 54 | 6 | 7 | 98 Following are the Even number: 2 54 6 98

Explanation / Answer


import java.util.*;
import java.lang.*;
import java.io.*;

class printArray
{
   public static void main (String[] args) throws java.lang.Exception
   {
   Scanner in = new Scanner(System.in);
System.out.println("How many numbers do you want to enter:(1-10) ");
int n = in.nextInt();
int[] num = new int[n];
for(int i=0;i<n;i++){
System.out.printf("enter number %d:",i+1);
num[i] = in.nextInt();
}
System.out.println("This is the content of the array:");
for(int i=0;i<n-1;i++){
System.out.printf("%d|",num[i]);
}
System.out.printf("%d ",num[n-1]);
System.out.println("Following are the even numbers:");
for(int i=0;i<n;i++){
if(num[i]%2==0)
System.out.printf("%d ",num[i]);
}
   }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote