Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

package org.

example;

import java.util.Scanner;

public class essaie2 {


private void erreur(String mes) throws Exception {
throw new Exception(mes);
}

public void essaieDexcetion(int a, int b) throws Exception


{
String resultat=" ";
if (a < b) {
resultat = a + " < " + b;

} else {
// resultat = a + " > " + b;
erreur(" ");
}
}

public static void main(String[] args) throws Exception {


Scanner LectureClavier = new Scanner(System.in);
System.out.println(" Entrez un nombre : ");
int nbr = 0;
try {
nbr = LectureClavier.nextInt();
System.out.println(" Saisir réussie. ");
} catch (Exception ex) {
System.out.println(" Erreur de saisie. Exception : " + ex);
}
float resultat;
LectureClavier.nextLine();
try {
resultat = nbr / 0;

} catch (Exception ex) {


System.out.println(" Exception : " + ex);
}
System.out.println(" " + nbr);
System.out.println(" Entrez un autre nombre (flottant) :");
float nbr2 = LectureClavier.nextFloat();
try {
essaie2.essaieDexcetion(9, 6);
} catch (Exception e)
{
System.out.println(e);
}

}
}

Non-static method 'essaieDexcetion(int, int)' cannot be referenced from a static


context

You might also like