Advertisement
Guest User

Untitled

a guest
Aug 27th, 2014
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. // @author Roner Reked
  5.  
  6. public class Calculator {
  7.  
  8. public static void main(String[] args) {
  9.  
  10. int x, y;
  11. String format;
  12.  
  13. Scanner z = new Scanner(System.in);
  14.  
  15. System.out.println("Ange tal 1: ");
  16. x = z.nextInt();
  17. System.out.println("Ange tal 2: ");
  18. y = z.nextInt();
  19.  
  20.  
  21. System.out.println("Ange +, -, /, *");
  22. format = z.next();
  23.  
  24. if (format.equals("+")) {
  25. System.out.println("" + x + " + " + y + " = " + (x + y));
  26.  
  27. } else if (format.equals("-")) {
  28. System.out.println("" + x + " - " + y + " = " + (x - y));
  29. } else if (format.equals("/")) {
  30. System.out.println("" + x + " / " + y + " = " + (x / y));
  31. } else if (format.equals("*")) {
  32. System.out.println("" + x + " * " + y + " = " + (x * y));
  33. }
  34.  
  35. }
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement