Test.java 1.23 KB
import java.util.*;

public class Test{

    
     
     
     
    public static void main(String[] args){
         Scanner sc = new Scanner(System.in);       
        //Choix Progression
        System.out.println("Arithmetique taper 1\n Geometrique taper 2 ");
        int choix = sc.nextInt();
        
        System.out.print("\npremier terme? ");
        double d = sc.nextDouble();
        System.out.print("\nraison? ");
        double raison = sc.nextDouble();
        Progression p;
        
        if(choix == 1){
            p= new ProgressionArithmetique(d,raison);
        } else {
            p= new ProgressionGeometrique(d,raison);
        }
        manip(p);
        
      
        
       
    }
   
    
    static void manip(Progression p){
    
        Scanner sc = new Scanner(System.in);
        System.out.print("\nnext (y/n)? ");
        char next = sc.next().charAt(0);
        while(next == 'y'){
            p.next();
            System.out.println("\n-> "+p.getTerme());
            
            System.out.print("next (y/n)? ");
            next = sc.next().charAt(0);
        }
        System.out.print("\nnb termes supplementaires? ");
        p.next(sc.nextInt());
        System.out.println("\n"+p.toString());
    }
    
}