1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Semmy [17]
3 years ago
14

Create a Java program that takes a list of integers as input from the user and outputs whether the list contains all even number

s, odd numbers, or neither. The input begins with the number of integers that will be stored in the list followed by the numbers to be stored in the array.
Computers and Technology
1 answer:
garik1379 [7]3 years ago
6 0

Answer:

This question is answered in Java programming language

import java.util.Scanner;

public class Main{

   public static void NumberTypes(int[]myarray){

       int evennum = 0; int oddnum = 0;

       for(int i = 1;i<=myarray[0];i++){

           if(myarray[i]%2==0){                evennum++;}

           else{                oddnum++;}

       }

   if(evennum == 0 && oddnum!=0){    System.out.print("Odd List");    }

   else if(evennum != 0 && oddnum==0){        System.out.print("Even List");    }

   else if(evennum != 0 && oddnum!=0){        System.out.print("None");    }

   }    

public static void main(String [] args){

int num;

Scanner input = new Scanner(System.in);

System.out.print("Length of list: ");

num = input.nextInt();

int [] myarray = new int[num+1];

myarray[0] = num;

for(int i = 1;i<num+1;i++){

myarray[i] = input.nextInt();

}

NumberTypes(myarray);

}

}

Explanation:

This question is answered in Java and it uses function to answer the question.  

The name of the function is NumberTypes

The program starts here

import java.util.Scanner;

public class Main{

The function NumberTypes starts here

   public static void NumberTypes(int[]myarray){

This line initializes even and odd to 0

       int evennum = 0; int oddnum = 0;

The following iteration iterates through the array

       for(int i = 1;i<=myarray[0];i++){

This checks if current array element is even. If yes, even variable is incremented by 1

           if(myarray[i]%2==0){                evennum++;}

This checks if current array element is odd. If yes, odd variable is incremented by 1

           else{                oddnum++;}

       }

If even is 0 and odd is not 0. The list is purely even number

   if(evennum == 0 && oddnum!=0){    System.out.print("Odd List");    }

If odd is 0 and even is not 0. The list is purely odd number

   else if(evennum != 0 && oddnum==0){        System.out.print("Even List");    }

If even and odd are not 0. The list is purely neither even nor odd  

   else if(evennum != 0 && oddnum!=0){        System.out.print("None");    }

   }    

The main method begins here

public static void main(String [] args){

This declares num; the length of array as integer

int num;

Scanner input = new Scanner(System.in);

This prompts the user for length of the array

System.out.print("Length of list: ");

This gets the length of the array

num = input.nextInt();

This declares the array as integer

int [] myarray = new int[num+1];

This initializes index 0 as the length of the array

myarray[0] = num;

The following iteration gets input for the array

<em>for(int i = 1;i<num+1;i++){ </em>

<em>myarray[i] = input.nextInt(); </em>

<em>} </em>

This calls the function

NumberTypes(myarray);

}

}

You might be interested in
In the MARS Marketing Management Simulation, the results of your marketing mix decisions:
azamat
C- are only occasionally affected by the decisions made by other teams
explanation
idk
3 0
4 years ago
Francis has designed a picture book appropriate for third graders. He wants teachers across the world to freely download use, an
mestny [16]

Answer:

The correct answer will be "Project Gutenberg".

Explanation:

  • Project Gutenberg continues to obtain lots of requests for authorization for using printed books, pictures, as well as derivatives from eBooks. Perhaps some applications should not be produced, because authorization would be included in the objects provided (as well as for professional usages).
  • You can copy, hand it over, or m actually-use it underneath the provisions including its license that was included in the ebook.

So that the above is the right answer.

8 0
3 years ago
All the read/write heads a hard disk are controlled by a(n) ____ which moves the read/write heads across the disk surfaces in un
Maru [420]

Answer:  b. actuator

Explanation:

We know that a RW head ( or also known as read/write head) is a component of device which is usually appeared on the hard drive which is used to read and write data by the hard drive's disk . When data required to be read or write, the read/write arm is regulated by actuator.

[An actuator is a part of a device that is mainly responsible for moving and controlling a mechanism or system.]

Hence, All the read/write heads a hard disk are controlled by an actuator .

5 0
3 years ago
Which of the following Wi-Fi chalking method refers to drawing symbols in public places to advertise open Wi-Fi networks?
dezoksy [38]

Answer War Chalking

Explanation: War chalking is the technique for presenting the WiFi network publicly. This signifies about the WiFi is present but not describes the manner of it , that is whether it is open connection or closed connection.

It can be used by the people in general as well as hackers . Hackers usually tend to attack and hack its security that is present.Hackers then use the WiFi network  is then used for their own work after being hacked.

3 0
3 years ago
Read 2 more answers
Olivia works at a company that creates mobile phones. She wanted to estimate the mean amount of time their new phone's battery l
Kisachek [45]

An swer:  

                               

 E. xpl an ation:    

                               

3 0
3 years ago
Other questions:
  • Behaving in an acceptable manner in a workplace environment is referred to as workplace etiquette.
    12·2 answers
  • IF YOU KNOW THE ANSWER TO THIS PLEASE ANSWER ASAP
    12·1 answer
  • You maintain an RODC running Windows Server 2012 R2 at a branch office, and you want Juanita, who has solid computer knowledge,
    13·1 answer
  • Please Help!!!<br> I keep getting this answer wrong
    10·1 answer
  • Which table attributes would this code produce?
    15·1 answer
  • Assuming that we only support BEQ and ADD instructions, discuss how changes in the given latency of this resource affect the cyc
    7·1 answer
  • In which conditions, a trial balance does not tally?
    14·1 answer
  • Who wants to join my Among us?<br><br><br>Code: EDQKNF <br><br><br>&lt;3333​
    9·2 answers
  • Why is it important to identify cables and conductors?​
    9·1 answer
  • Typically, hybrid drives use SSD to store the operating system and applications and hard disks to store videos, music, and docum
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!