Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //**********************************************************
- // Nom: Marven Regimbald
- // Date: 2018-01-17
- // Description:
- //**********************************************************
- // Packages d'extension Java.
- import javax.swing.JOptionPane;
- public class ExamenMarvenRegimbald {
- // La methode main debute l'execution de l'appl. Java.
- public static void main( String args[] ) {
- int UnInt;
- int essai=0;
- int num=0;
- int num1;
- int num2;
- int op = 0;
- int somme = 0;
- String str1;
- boolean debugg =true ;
- boolean correct = false;
- int count = 0; //stores how many correct answers
- for(int i = 0; i < 10; i++)
- {
- num1 = (int) (Math.random() * 10 + 0);
- num2 = (int) (Math.random() * 10 + 0);
- op = (int) (Math.random() * 5 + 1);
- int e = 0;
- correct = false;
- while(e < 3 && !correct) {
- if (op == 1) {
- somme = num1 + num2;
- String input = JOptionPane.showInputDialog(null, "Quelle est la réponse de "+num1+" + "+num2+" = ");
- if (Integer.toString(somme).equals(input)){
- count++;
- correct = true;
- }
- else
- e++;
- } else
- if (op == 2){
- somme = num1 - num2;
- String input = JOptionPane.showInputDialog(null, "Quelle est la réponse de "+num1+" - "+num2+" = ");
- if (Integer.toString(somme).equals(input)){
- count++;
- correct = true;
- }
- else
- e++;
- }
- if (op == 3){
- somme = num1 * num2;
- String input = JOptionPane.showInputDialog(null, "Quelle est la réponse de "+num1+" * "+num2+" = ");
- if (Integer.toString(somme).equals(input)){
- count++;
- correct = true;
- }
- else
- e++;
- }
- if (op == 4){
- somme = num1 / num2;
- String input = JOptionPane.showInputDialog(null, "Quelle est la réponse de "+num1+" / "+num2+" = ");
- if (Integer.toString(somme).equals(input)){
- count++;
- correct = true;
- }
- else
- e++;
- }
- if (op == 5){
- somme = num1 % num2;
- String input = JOptionPane.showInputDialog(null, "Quelle est la réponse de "+num1+" % "+num2+" = ");
- if (Integer.toString(somme).equals(input)){
- count++;
- correct = true;
- }
- else
- e++;
- }
- }
- }
- System.out.println(count);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement