/* calcul le carre du sinus d'un reel donne */ public class Sinus { public static void main ( String [] arg ) { if( arg[0].startsWith("PI") ) { if( arg[0].length() == 2 ) System.out.println( Math.sin(Math.PI)); if( arg[0].startsWith("/",2) ) { int n = arg[0].length(); Double a = new Double(arg[0].substring(3,n)); //ou: Double a = Double.valueOf(arg[0].substring(3,n)); System.out.println( Math.sin(Math.PI /a.doubleValue())); //direct: System.out.println( Math.sin(Math.PI/new Double(arg[0].substring(3,n)).doubleValue())); } } else { Double a = new Double(arg[0]); //ou: Double a = Double.valueOf(arg[0]); System.out.println( Math.sin(a.doubleValue())); //direct: System.out.println( Math.sin(new Double(arg[0]).doubleValue())); } } }