Advertisement
Benlahbib_Abdessamad

Untitled

Sep 7th, 2015
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.56 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class Test {
  5.    
  6.    
  7.    
  8.     public static void main(String args[])
  9.     {
  10.         int i=0;
  11.         int sum=0;
  12.         int produit=1;
  13.         double div=1;
  14.         Scanner sc=new Scanner(System.in);
  15.         System.out.print("Veuillez inserer l operateur : ");
  16.         String str=sc.nextLine();
  17.        
  18.         if(str.equals("+"))
  19.         {
  20.             while(i!=1)
  21.             {
  22.                 Scanner sr=new Scanner(System.in);
  23.                 System.out.print("Inserer un nombre entier : ");
  24.                 String strs=sr.nextLine();
  25.                 if(strs.equals("Ende"))
  26.                 {
  27.                     i=1;
  28.                 }
  29.                
  30.                 else
  31.                 {
  32.                     sum=sum+Integer.parseInt(strs);
  33.                 }
  34.             }
  35.            
  36.             System.out.println("Summe : " +sum);
  37.         }
  38.        
  39.         else if(str.equals("*"))
  40.         {
  41.             while(i!=1)
  42.             {
  43.                 Scanner sr=new Scanner(System.in);
  44.                 System.out.print("Inserer un  nombre entier : ");
  45.                 String strp=sr.nextLine();
  46.                 if(strp.equals("Ende"))
  47.                 {
  48.                     i=1;
  49.                 }
  50.                
  51.                 else
  52.                 {
  53.                     produit=produit*Integer.parseInt(strp);
  54.                 }
  55.             }
  56.            
  57.             System.out.println("Produit : " +produit);
  58.         }
  59.        
  60.         else if(str.equals("/"))
  61.         {
  62.             int counter=0;
  63.             while(i!=1)
  64.             {
  65.                 Scanner sr=new Scanner(System.in);
  66.                 System.out.print("Inserer un  nombre  : ");
  67.                 String strd=sr.nextLine();
  68.                 if(strd.equals("Ende"))
  69.                 {
  70.                     i=1;
  71.                 }
  72.                
  73.                 else
  74.                 {
  75.                     if (counter==0)
  76.                     {
  77.                         div=Double.parseDouble(strd);
  78.                         counter++;
  79.                     }
  80.                     else
  81.                     {
  82.                         div=div/Double.parseDouble(strd);
  83.                         counter++;
  84.                     }
  85.                    
  86.                 }
  87.             }
  88.            
  89.             System.out.println("Division : " +div);
  90.         }
  91.        
  92.        
  93.        
  94.        
  95.        
  96.        
  97.        
  98.        
  99.     }
  100.  
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement