Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2. Answer the following in JAVA a) You are writing code for a cleaning robot. The robot will keep cleaning until either the battery is

2. Answer the following in JAVA

a) You are writing code for a cleaning robot. The robot will keep cleaning until either the battery is low (less than 20%) or the dustpan area is nearly full (more than 95%). Write a public function that has two arguments: a float, called batteryPower which is a percentage from 0 to 100 and a float called dustPan also a percentage from 0 (empty) to 100 (full). This should return true if the battery is low or the dustpan is full, indicating it is time to go back to the power dock, otherwise it should return false (keep cleaning).

b) Write a function that takes in an ArrayList of Strings called words as a parameter, and returns the middle value in the list. If the middle item is a even (list size 4) then return the rounded item (3). So for { A,B,C } return B; for { A,B,C, D } return C; Remember indexing is from 0.

c) Write a function that takes in an Array of integers called numbers as a parameter, and returns the middle value in the list. If the middle item is a even (e.g. list size 4) then return the rounded item (3). So for { 11,12,13} return 12 for { 11,12,13,24} return 13. Remember indexing is from 0.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

3rd Edition

0128012757, 978-0128012758

More Books

Students also viewed these Databases questions

Question

DEFINE human resources planning (HRP) and

Answered: 1 week ago