positions of the first and last zero element in the given array. For example if the array is 3 0 1 0 4 9 5 0 6 your algorith

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter2: Using Data
Section: Chapter Questions
Problem 14RQ
icon
Related questions
Question
Compute the distance between the positions of the first and last zero element in the given array. For example if the array is 3 0 1 0 4 9 5 0 6 your algorithm should yield 7 - 1 = 6. If the array contains a single zero return 0. If it doesn’t contain any zeros return a negative value Only edit code within the /*Your code goes here*/ portion.
) src)
Numbers
PasswordGenerator.java =
PrintDemo.java X
A G Pyramids.java ×
Prog06_PartyPooper.java X
public class Numbers
CObes
1
DoLoop
2
G Doublelnvesti
G DuplicatedCh 3 @
G EarthquakeSt 4
GElevatorSimul 5
public static int zeroesDistance(double[] values)
{
int firstPos = 0;
int lastPos = values. Length - 1;
Error1
6
Error2
7
boolean found = false;
G Error3
while (firstPos < values.length && !found)
8
O FindSpaces
9
A FirstVowel.jav
/* Your code goes here */
10
G Geometry
G Grades
11
12
return lastPos - firstPos;
HelloPrinter
G IntegerName| 13
G InvestmentTal 14
l joh661.zip
Numbers
PasswordGen
G PowerTable
G PrintDemo
PrintTableDer
G Prog06_Party
G Pyramids
G RandomDemd
GReadTime
GReciprocalSu
RemoveDupli
G SentinelDemd
> G Seperators.ja
G Shipping
G TaxCalculator
G test
UniqueChars
Velumed
Run:
O ArrayDemo x
ZUsers/jacobjohnston/Library/Java/JavaVirtualMachines/openidk-16.0.2/Contents/Home/bin/java -j-
0 246 8
Fred Amy Cindy Henry
42 2 4 6 8
Enter scores, -1 to quit:
12 25 20 0 10 -1
You entered the following scores:
12 25 20 0 10
Process finished with exit code 0
E TODO
O All files are up-to-date (10/30/21, 2:15 PM)
> Run
O Problems
2 Terminal
K Build
* Favorites
Structure
4/- 印|1|大
Transcribed Image Text:) src) Numbers PasswordGenerator.java = PrintDemo.java X A G Pyramids.java × Prog06_PartyPooper.java X public class Numbers CObes 1 DoLoop 2 G Doublelnvesti G DuplicatedCh 3 @ G EarthquakeSt 4 GElevatorSimul 5 public static int zeroesDistance(double[] values) { int firstPos = 0; int lastPos = values. Length - 1; Error1 6 Error2 7 boolean found = false; G Error3 while (firstPos < values.length && !found) 8 O FindSpaces 9 A FirstVowel.jav /* Your code goes here */ 10 G Geometry G Grades 11 12 return lastPos - firstPos; HelloPrinter G IntegerName| 13 G InvestmentTal 14 l joh661.zip Numbers PasswordGen G PowerTable G PrintDemo PrintTableDer G Prog06_Party G Pyramids G RandomDemd GReadTime GReciprocalSu RemoveDupli G SentinelDemd > G Seperators.ja G Shipping G TaxCalculator G test UniqueChars Velumed Run: O ArrayDemo x ZUsers/jacobjohnston/Library/Java/JavaVirtualMachines/openidk-16.0.2/Contents/Home/bin/java -j- 0 246 8 Fred Amy Cindy Henry 42 2 4 6 8 Enter scores, -1 to quit: 12 25 20 0 10 -1 You entered the following scores: 12 25 20 0 10 Process finished with exit code 0 E TODO O All files are up-to-date (10/30/21, 2:15 PM) > Run O Problems 2 Terminal K Build * Favorites Structure 4/- 印|1|大
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT