Guest User

Untitled

a guest
Feb 21st, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1. //Calculatrice
  2. import java.util.Scanner;
  3.  
  4. public class Calculatrice
  5. {
  6.     public static void main (String[] args)
  7.     {
  8.         System.out.print("Quelle opération désirez vous effectuer? (Addition,Soustraction,Multiplication,Division) ");
  9.         Scanner sc = new Scanner(System.in);
  10.         String choix = sc.nextLine();
  11.         System.out.println("Entrez les 2 nombres dans l'ordre");
  12.         double num1 = sc.nextDouble();
  13.         double num2 = sc.nextDouble();
  14.        
  15.         if (choix.charAt(0)=='A')
  16.             System.out.println(num1+num2);
  17.         if (choix.charAt(0)=='S')
  18.             System.out.println(num1-num2);
  19.         if (choix.charAt(0)=='M')
  20.             System.out.println(num1*num2);
  21.         if (choix.charAt(0)=='D')
  22.             System.out.println(num1/num2);
  23.     }
  24. }
Add Comment
Please, Sign In to add comment