first time posting here and I'd like some help , I started learning java some days ago and I tried to make a very simple calculator. Here is the code :
import java.util.Scanner;
public class Calc {
public static void main(String[] args) {
while (true) {
Scanner input = new Scanner(System.in);
double input1, input2;
System.out.println("Type your calculation below");
input1 = input.nextDouble();
String operator = input.next();
input2 = input.nextDouble();
switch (operator) {
case "+":
System.out.println(input1 + input2);
break;
case "-":
System.out.println(input1 - input2);
break;
case "*":
System.out.println(input1 * input2);
break;
case "/":
System.out.println(input1 / input2);
break;
}
}
}
}
When I run this I have to type a number press space and then type the other number like this : 15 + 15. Can I somehow make it so that I don't have to press space every time? So I can type it like this : 15+15.
Also if you have any tips or if you see any mistakes I'd be happy to hear your opinion.