Advertisement
Guest User

Untitled

a guest
Jun 26th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Kalkulator {
  3. public static void main(String args[]){
  4.  
  5. Scanner skener = new Scanner(System.in);
  6. int num1, num2, answerNum;
  7.  
  8. int x;
  9.  
  10. System.out.println("Enter first number: ");
  11. num1 = skener.nextInt();
  12.  
  13. System.out.println("Enter your second number: ");
  14. num2 = skener.nextInt();
  15.  
  16. System.out.println("What operator would you like to use?");
  17. System.out.println("For addition please type in number 1");
  18. System.out.println("For subtraction please type in number 2");
  19. System.out.println("For multiplication please type in number 3");
  20. System.out.println("For division please type in number 4");
  21. x = skener.nextInt();
  22.  
  23. If (x == 1){
  24. answerNum = num1 + num2;
  25.  
  26. }
  27.  
  28. If (x == 2){
  29. answerNum = num1 - num2;
  30.  
  31.  
  32. }
  33. If (x == 3){
  34. answerNum = num1 * num2;
  35.  
  36.  
  37. }
  38. If (x == 4){
  39. answerNum = num1 / num2;
  40.  
  41. }
  42.  
  43. System.out.println(answerNum);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement