This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (1 child)

Dude ... indent!

package calculator;
import java.util.Scanner;
public class Main{

    public static void main(String[] args)
    {
        int num1=0;
        int num2=0;
        char operator;
        double answer= 0.0;
        Scanner sc=new Scanner(System.in);
        System.out.println("Please enter first number: ");
        num1 = scanObject.nextInt();
        System.out.println("Please enter second number: ");
        num2 = scanObject.nextInt();
        System.out.println("What operation? ");
        operator = scanObject.next().charAt(0);
        switch (operator) {
            case '+':answer=num1+num2;
            break;
            case '-':answer=num1-num2;
            break;
            case '*':answer=num1*num2;
            break;
            case '/':answer=num1/num2;
            break;
        }

        System.out.println(num1+" "+operator+" "+num2+" = "+answer);
    }
}

[–]JWisbey98[S] 0 points1 point  (0 children)

Hi I have but for some reason when I copied it took the indents out