Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- // @author Roner Reked
- public class Calculator {
- public static void main(String[] args) {
- int x, y;
- String format;
- Scanner z = new Scanner(System.in);
- System.out.println("Ange tal 1: ");
- x = z.nextInt();
- System.out.println("Ange tal 2: ");
- y = z.nextInt();
- System.out.println("Ange +, -, /, *");
- format = z.next();
- if (format.equals("+")) {
- System.out.println("" + x + " + " + y + " = " + (x + y));
- } else if (format.equals("-")) {
- System.out.println("" + x + " - " + y + " = " + (x - y));
- } else if (format.equals("/")) {
- System.out.println("" + x + " / " + y + " = " + (x / y));
- } else if (format.equals("*")) {
- System.out.println("" + x + " * " + y + " = " + (x * y));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement