[hotjoe.com] HotJoe Java Help Forums
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Visit java.com
Please send email if you are having login problems - see the posts below for more info.
Hotmail and Yahoo! users - please see the Hotmail post or the Yahoo! post for information on lost emails.
Help with homework - scanner problems  XML
Forum Index » Java Programming
Author Message
unknownterra

Newbie
[Avatar]

Joined: 03/22/2006 20:08:52
Messages: 10
Offline

Thanks heaps! I didn't know I should do that.
heathfree

Newbie

Joined: 03/16/2006 06:45:12
Messages: 20
Offline

so it looking for a next int how do I fix it????
tfecw

Newbie

Joined: 09/19/2005 15:02:20
Messages: 144
Location: No. VA.
Offline

stdunbar wrote:No, it isn't your code it is your input. You said you ran it with


The first number has to be an integer because that is the first scanner thing you're looking for.


(quoting to move this to page 2 )

To fix the problem you do basically what stdunbar said to do.

12.5 is not an Integer, which is what your code is looking for as the first input. To fix the problem would be to change your input.

Give something like:
3 12.5 15.5 9.2

a shot
aim icon
heathfree

Newbie

Joined: 03/16/2006 06:45:12
Messages: 20
Offline

but that is not how that program is suppose to run I tried moving the amount=s.nextDouble();up in front of the int but it still gives me that same problem. So now what?????? I am really not liking the scanner
heathfree

Newbie

Joined: 03/16/2006 06:45:12
Messages: 20
Offline

enter all amounts collected separated by spaces,terminated with a -1
1 12.3 13.4 12.9 -1
Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Scanner.java:819)
at java.util.Scanner.next(Scanner.java:1431)
at java.util.Scanner.nextInt(Scanner.java:2040)
at java.util.Scanner.nextInt(Scanner.java:2000)
at AutoGarage.main(AutoGarage.java:25)
Press any key to continue . . .
Still giving the same problem
heathfree

Newbie

Joined: 03/16/2006 06:45:12
Messages: 20
Offline

at the school right now tutor has not showed up was suppose to be here at 10 can not get any help from this college.
tfecw

Newbie

Joined: 09/19/2005 15:02:20
Messages: 144
Location: No. VA.
Offline



This is the most current code you've posted. FOr your input to work you MUST input an Integer, followed by 3 doubles.

if you want to enter the -1 last, ou need to change your code to look something like the following.


Now your input needs to be 3 doubles followed by an int.

This message was edited 1 time. Last update was at 03/24/2006 08:40:32

aim icon
heathfree

Newbie

Joined: 03/16/2006 06:45:12
Messages: 20
Offline

I fix it the tutor finally showed up.
 
Forum Index » Java Programming
Go to:   
Powered by JForum 2.1.9 © JForum Team
This site run by Scott Dunbar of Xigole Systems. © 2005-2011 - Scott Dunbar
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners
hotjoe.com, xigole.com, and Scott Dunbar have no affiliation with Oracle