The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 364 Weeks Ago, 2 Days Ago |
| Questions Answered: | 1850 |
| Tutorials Posted: | 1850 |
Graduate in Biology and Nutrition, MBA Finance
Florida State University
Aug-2000 - Jul-2007
Ass. Relationship Manager
Penn-Florida
Mar-2009 - Feb-2016
Q1: countPositiveÂ
We want to implement the method countPositive which does what the Python function count_pos was doing.
To simplify things, we are not going to prompt the user. Instead, we are going to assume that a space-separated list of integers is passed on to the program as an argument. Here are two sample runs of our program:
> java A1Q1 1 2  3 0 5 -6 9 Â
5 Â
Â
> java A1Q1 -5 -6 -9 Â
0
Â
Q2: hasTwoLengthRunÂ
We want to implement the method hasTwoLengthRun which does what the Python function two_length_run was doing.
As before, the input will come from the command line. Here are some sample runs:
> java A1Q2 Â
false Â
Â
> java A1Q2 0 Â
false Â
Â
> java A1Q2 0 1 Â
false Â
Â
> java A1Q2 0 0 Â
true Â
Â
> java A1Q2 0 1 2 3 3 4 5 Â
true Â
Â
> java A1Q2 0 1 2 3 4 5 5 Â
true Â
Â
> java A1Q2 0 1 2 3 4 5 Â
false Â
Â
> java A1Q2 0 1 2 3 4 5 0 Â
false
Â
Q3: getLongestRunÂ
We want to implement the method getLongestRun which does what the Python function longest_run was doing.
As before, the input will come from the command line. Here are some sample runs:
> java A1Q3 Â
0 Â
Â
> java A1Q3 0 1 1 0 3 Â
2 Â
Â
> java A1Q3 0 1 0 3 Â
1 Â
Â
> java A1Q3 0 1 0 3 4  4  4  4 0 0 Â
4 Â
Â
> java A1Q3 1 1 2 3 3 3 3 3 6 5 Â
5 Â
Â
> java A1Q3 6 6 7 1 1 1 1 4 1 Â
4 Â
Â
> java A1Q3 6 2 4 8 6 Â
1 Â
Hel-----------lo -----------Sir-----------/Ma-----------dam----------- Â----------- -----------Tha-----------nk -----------you----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------acq-----------uis-----------iti-----------on -----------of -----------my -----------pos-----------ted----------- so-----------lut-----------ion-----------.Pl-----------eas-----------e p-----------ing----------- me----------- on----------- ch-----------at -----------I a-----------m Â----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I