1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| import java.util.Scanner;
public class winnitest {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("---------------------------------");
System.out.println(" suite arithmetique by moi ");
System.out.println("---------------------------------");
char reponse = 'O';
Scanner sc = new Scanner(System.in);
while (reponse == 'O')
{
System.out.println( "saisissez U1" );
double u1 = sc.nextDouble();
System.out.println( "saisissez la raison");
double raison = sc.nextDouble();
if (raison == 0)
System.out.println("la raison n'est pas valide");
else
System.out.println("saisissez Un");
int nterme= sc.nextInt();
double result = (double)(u1)+ (double)(--nterme) * raison ;
System.out.println("---------------------------------");
System.out.println(" suite arithmetique resultat ");
System.out.println("---------------------------------");
System.out.println("U1 = " +u1+ "|" );
System.out.println("raison = " +raison+ "|" );
System.out.println("U"+ ++nterme+ "=" + result);
System.out.println("Voulez-vous réessayer ?(O/N)");
reponse = sc.nextLine().charAt(0);
}
System.out.println("Au revoir...");
}
} |