Probleme de compilation
sandy
-
Sandy -
Sandy -
Bonjour,
voici mon programme je suis novice en java et je ne comprends pas pk ça ne marche pas on me dit:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2
at essai2.main(essai2.java:14)
import java.util.Scanner;
public class essai2 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in) ;
int contenance = sc.nextInt();
int pvd = 0;
int premiersNombres[][] = { {30,50,100},{43,64,79} };
if (contenance == 30) {
pvd = premiersNombres[2][1];
}
if (contenance == 50) {
pvd = premiersNombres[2][2];
}
if (contenance == 30) {
pvd = premiersNombres[2][3];
}
System.out.println ("le prix de vente est " + pvd);
}}
voici mon programme je suis novice en java et je ne comprends pas pk ça ne marche pas on me dit:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2
at essai2.main(essai2.java:14)
import java.util.Scanner;
public class essai2 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in) ;
int contenance = sc.nextInt();
int pvd = 0;
int premiersNombres[][] = { {30,50,100},{43,64,79} };
if (contenance == 30) {
pvd = premiersNombres[2][1];
}
if (contenance == 50) {
pvd = premiersNombres[2][2];
}
if (contenance == 30) {
pvd = premiersNombres[2][3];
}
System.out.println ("le prix de vente est " + pvd);
}}
A voir également:
- Probleme de compilation
- Breach compilation c'est quoi - Guide
- Compilation error: expected unqualified-id before '{' token ✓ - Forum C++
- Erreur de compilation projet ou bibliothèque introuvable - Forum Excel
- Erreur de compilation : Projet ou bibliothèque introuvable - Forum VB / VBA
- Must declare a named package because this compilation unit is associated to the named module - Forum Java
Je sais que le tableau fonctionne mais juste l affichage ne marche pas