Java:investment equation
Résolu
domxaline
Messages postés
204
Statut
Membre
-
domxaline Messages postés 204 Statut Membre -
domxaline Messages postés 204 Statut Membre -
Bonjour,
j'écris ce programe,quand je rentre le chiffre dans le r:
exemple 0.10
il montre un erreur,aidez moi svp
Enter the value of P:1000
Enter the value of r:0.10
Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Unknown Source)
at java.util.Scanner.next(Unknown Source)
at java.util.Scanner.nextFloat(Unknown Source)
at WhileTest.main(WhileTest.java:14)
j'écris ce programe,quand je rentre le chiffre dans le r:
exemple 0.10
il montre un erreur,aidez moi svp
import java.util.Scanner;
public class WhileTest
{
public static void main (String []args)
{
Scanner input=new Scanner(System.in);
System.out.print("Enter the value of P:");
//double p=input.nextDouble();
float p=input.nextFloat();
System.out.print("Enter the value of r:");
//double r=input.nextDouble();
float r=input.nextFloat();
System.out.print("Enter the value of n:");
//double n=input.nextDouble();
float n=input.nextFloat();
float v1=1+r;
float v2=(float) Math.pow(v1,n);
double v=(float)p*v2;
Float d=new Float(v);
System.out.print(d);
}
}
Enter the value of P:1000
Enter the value of r:0.10
Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Unknown Source)
at java.util.Scanner.next(Unknown Source)
at java.util.Scanner.nextFloat(Unknown Source)
at WhileTest.main(WhileTest.java:14)
A voir également:
- Java:investment equation
- Jeux java itel - Télécharger - Jeux vidéo
- Waptrick java football - Télécharger - Jeux vidéo
- Eclipse java - Télécharger - Langages
- Waptrick java voiture - Télécharger - Jeux vidéo
- Java apk - Télécharger - Langages
Enter the value of P:1000
Enter the value of r:0,10
Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Unknown Source)
at java.util.Scanner.next(Unknown Source)
at java.util.Scanner.nextLong(Unknown Source)
at java.util.Scanner.nextLong(Unknown Source)
at WhileTest.main(WhileTest.java:14)
j'ai mis tous en double,et essayé comme tu m'avais dit
maintenant ça marche