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: | 304 Weeks Ago, 1 Day Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
Write a public class call CountConsecutiveChars.
class CountConsecutiveChars has only one method called run.
specs for run:
name: run
returns: nothing
arguments: none
what it does: it uses the Scanner class to input a String entered by
the user. It prints the number of times characters
repeat. It reports the sum of all the runs as well as
the size of the largest. Look at the examples.
"number" is the number of times a character was repeated
consecutively. Lets call that a "run". "max" is the
size of the largets run. For example is the String is:
"aaxbbb", then the sum of all characters that were
repeated consecutively is 5 because a repeats 2 times
and b repeats 3 times. The largest run was 3 (the b's).
Examples of runs:
% java CountConsecutiveChars
Enter a string: a
The number is 0
The max is 0
% java CountConsecutiveChars
Enter a string: aaa
The number is 3
The max is 3
% java CountConsecutiveChars
Enter a string: aaxbbb
The number is 5
The max is 3
% java CountConsecutiveChars
Enter a string: aaax
The number is 3
The max is 3
% java CountConsecutiveChars
Enter a string: aaxbbbxcc
The number is 7
The max is 3
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly