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
Y_Kistochka [10]
3 years ago
5

Write a function findEvenQueue that returns the first even number in the Queue. The function looks at the value at the front of

the queue and checks if it’s even. If the value is even, then it returns that number. If the value is not even, then it removes that item from the queue and the process is repeated checking the front of the queue again. The function should return -1 if there are no even numbers. HINT: The program should make use of the peek method and the poll method of the queue.
Computers and Technology
1 answer:
Bumek [7]3 years ago
4 0

Answer:

Check the explanation

Explanation:

CODE:

static int findEvenQueue(Queue<Integer> numbers)

{

//loop runs till the queue has atleast one element

while(numbers.size() > 0)

{

//Checking the head of the queue whether it is even

int temp = numbers.peek();

if(temp % 2 == 0)

{

//if the head is even then return it

return temp;

}

else

{

//else remove the number at head

int removed = numbers.poll();

}

}

//if no even number present in the Queue then return -1

return -1;

}

You might be interested in
Which image file format is the most widely used?
Ostrovityanka [42]

Answer: jpeg because its a lot of people use it for quaity

7 0
2 years ago
"what type of device special file is typically used for devices connected to usb ports?"
pochemuha
<span>The character as a type of device special file is typically used for devices connected to USB ports.
</span>These character<span> special </span>files<span> are also called </span>character<span> devices. They provide unbuffered, direct access to the hardware device. </span>
7 0
3 years ago
?An active card, which contains an internal battery, can provide a usable range of up to what distance
lianna [129]
An active card is used in relation to computers and technology, it has the component of an internal battery and wouldn't be used without it. The active card can provide a usable range of up to 150 m distance. And this is the distance of how far that it could get.
6 0
3 years ago
The protection of the confidentiality, integrity, and availability of information assets, whether in storage, processing, or tra
Sergeu [11.5K]

Answer: Information security

Explanation:

 The information security is one of the system that keeps the data confidential, assure the integrity and also availability of the information or data.

This system is basically refers as the CIA triad in the information security system and the data risk management.

The main aim of the information security is that keeps the data protected from the unauthorized accessing and also  controlling the access in the system.

Therefore, Information security is the correct answer.

8 0
4 years ago
What is the phase shift for the following?A sine wave with zero amplitude after 3/4 cycle and increasing.Show by drawing on grap
frozen [14]

Answer:I think so

Explanation:

7 0
4 years ago
Other questions:
  • A small company has developed a specialized software product that it configures specially for each customer. New customers usual
    14·1 answer
  • Which icon will automatically adjust the amount of space between letters from very tight to very loose in style? Hyphenation, Te
    6·2 answers
  • Parts are described by partnum, color, and price. Parts can be subassemblies as well and this means that they contain other part
    12·1 answer
  • Maureen downloads three pictures of cabin sizes for her siblings to vote on. She inserts one picture per slide. The third pictur
    10·1 answer
  • In the space provided, analyze the pros and cons of becoming a member of an artistic guild. Your answer should be at least 150 w
    12·1 answer
  • Write an algorithm to sum to values
    11·1 answer
  • what is required to successfully establish a connection between two routers using chap authentication?
    14·1 answer
  • Flight controllers make sure the facilitates that house mission control can operate properly, even in the event of a severe weat
    6·1 answer
  • Which structure is the arrow pointing to?<br><br> What is the function of this organelle?
    6·1 answer
  • Value (related to the five 'v's' of big data) addresses the pursuit of a meaningful goal. true false
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!