Hey
Iīm trying to make a calcylator in java. First you write the first number, then the second number and then the unit(+,-/ or *). But i only get lots of errors the whole time and i canīt see my problem.
Hereīs my code
import java.util.Scanner; class KO{ public static void main(String args[]){ Scanner Alexander = new Scanner(System.in); double fnum, snum, unit, answer; System.out.println("Write fnum: "); fnum = Alexander.nextDouble(); System.out.println("write snum: "); snum = Alexander.nextDouble(); System.out.println("+,-,/,*: "); unit = Alexander.nextDouble(); if (unit = +) { answer = fnum + snum; }if (unit = -) { answer = fnum - snum; System.out.println(answer); } } }
And the errors is.
calculator2.java:13; error: illegal start of expression
if (unit = +) {
calculator2.java:15: error illegal start of expression
} if (unit = -) {
Sincrerly
JustACode