import java.util.Scanner;
public class Basic {
public static void main(String[] args) {
Scanner CalcType = new Scanner(System.in);
double fnum, snum;
String math;
System.out.println("--------------------------------------------------");
System.out.println("Welcome to the basic calculator made by codermadi!");
System.out.println("--------------------------------------------------");
System.out.println("Enter first number!");
System.out.println("--------------------------------------------------");
fnum = CalcType.nextDouble();
System.out.println("--------------------------------------------------");
System.out.println("Enter second number!");
System.out.println("--------------------------------------------------");
snum = CalcType.nextDouble();
System.out.println("--------------------------------------------------");
System.out.println("+ | - | / | x | %");
System.out.println("--------------------------------------------------");
math = CalcType.next();
if (math == "+") {
System.out.println(fnum + snum);
}
if (math == "-") {
System.out.println(fnum - snum);
}
if (math == "/") {
System.out.println(fnum / snum);
}
if (math == "*") {
System.out.println(fnum * snum);
}
if (math == "x") {
System.out.println(fnum * snum);
}
if (math == "%") {
System.out.println(fnum % snum);
}
System.out.println("-------------------------------------------");
System.out.println("Thank you for using codermadi's calculator!");
System.out.println("-------------------------------------------");
}
}
I have a problem, when I type the type of math I want my calculator to do it doesn't output the if statements.. My problem is at the bold text.
-
-
-
-
Had to add these because StackOverFlow wants me to add more details.