+ 1

when i use scanner (nextfloat ) i get unputmismatexception

19th Sep 2017, 1:16 PM
riadh
4 Réponses
+ 5
Show all their parts can you? nextFloat() not nextfloat It is method not property
19th Sep 2017, 3:36 PM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
+ 4
Is the input a float? Post your code. Typically you'll generate such an error if the input is different than what you're trying to obtain. So if the next piece of data isn't a float, you can't use nextFloat to obtain it. You can use hasNextFloat() to check if it's a float before you do any operations with it. If it's a float, then do nextFloat(). If not, then don't. Get what I mean?
19th Sep 2017, 1:25 PM
AgentSmith
0
public class Program { import java.util.Scanner ; public static void main(String[] args) { calmoy m = new calmoy (); Scanner s = new Scannee(System .in); System .out .print ("donner votre prix ") m.setprix(s.nextfloat); System.out.println ("prix est " + m.getprix()) } }
19th Sep 2017, 1:40 PM
riadh
0
i use set and get methode and in setmethod i writ setExemple(float d) { this.____= d; } so in scanner must use nextfloat!?
19th Sep 2017, 1:48 PM
riadh