I am trying to make a program where I enter the name of a shape and it tells me how many sides it has. I cannot seem to get it to work. Can anyone explain how to do this?
import java.util.Scanner;
public class Shapes {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
String shape;
System.out.print("Enter shape: ");
shape = reader.next();
if (shape == "hexagon") {
System.out.println("A hexagon has 6 sides.");
}
if (shape == "decagon"); {
System.out.println("A decagon has 10 sides.");
}
}
}