Enter a string: jason is jack
No. of 'J' / 'j' = 1
If you would like to run the program for another string please enter 1.
Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Scanner.java:840)
at java.util.Scanner.next(Scanner.java:1461)
at java.util.Scanner.nextInt(Scanner.java:2091)
at java.util.Scanner.nextInt(Scanner.java:2050)
at countletter.main(Project5B.java:36)
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.
> <jcsencs...@yahoo.com> wrote in messagenews:1169581171.928377.257750@l53g2000cwa.googlegroups.com...>I am trying to get this to print the number of J's there are in the
> > users input. and then ask if they want to try again. can someone help
[quoted text clipped - 3 lines]
>
> - Oliver
Gordon Beaton - 24 Jan 2007 07:15 GMT
> Enter a string: jason is jack
>
> No. of 'J' / 'j' = 1
You need to read the documentation for Scanner.next().
Doing so might also help you understand why you get the
following exception:
> Exception in thread "main" java.util.InputMismatchException
/gordon

Signature
[ don't email me support questions or followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
jcsencsits@yahoo.com - 24 Jan 2007 14:40 GMT
it works for one word but when i do a sentence is when it fails
> > Enter a string: jason is jack
>
[quoted text clipped - 8 lines]
> [ don't email me support questions or followups ]
> g o r d o n + n e w s @ b a l d e r 1 3 . s e
Gordon Beaton - 24 Jan 2007 14:48 GMT
> it works for one word but when i do a sentence is when it fails
That was clear from your earlier example. Scanner.next() does not
return the entire line entered by the user, as you seem to expect. Did
you read its documentation as I suggested?
Try displaying the contents of the randomString along with the
corresponding J count.
/gordon

Signature
[ don't email me support questions or followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e