Bonjour, que pensez-vous de ces 2 algos :
Code java : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import java.util.Scanner;
 
public class Ex7serie3{
 
 
public static void main (String[] args)
{
    double n,somme=0;
    System.out.println("Saisir n");
    n= (new Scanner(System.in)).nextDouble();
 
    while (n!=-1){
        somme=somme+n;
 
        System.out.println("Saisir n");
        n= (new Scanner(System.in)).nextDouble();
        System.out.println(somme+n);
 
    }
    System.out.println("you loose");
    }
 
    }
et
Code java : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import java.util.Scanner;
 
public class exercice{
 
 
public static void main (String[] args)
{
    double a,b;
      System.out.println("Saisir a");
      a= (new Scanner(System.in)).nextDouble();
      System.out.println("Saisir b");         
      b= (new Scanner(System.in)).nextDouble();
      while (a+b>0){
 
          System.out.println(a+b);
          System.out.println("Vous pouvez-continuer");
          System.out.println("Saisir a");
          a= (new Scanner(System.in)).nextDouble();
          System.out.println("Saisir b");         
          b= (new Scanner(System.in)).nextDouble();
      }
      System.out.println("Cassez-vous");
      }
}