I have a problem with inputs in the code. In the program I want to create a menu which allows us to put shapes in it. In the first option when I write square, circle or rectangle the program should ask me side, radius or height and width. However when I write the kind of the shape the program goes back to menu as nothing happened. Could you help?
import java.util.*;
public class test
{
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
Scanner scan2 = new Scanner(System.in);
String kindofshape;
int choice, radius, width, height, side;
do
{
System.out.println("(1) Add a shape to the list");
System.out.println("(2) Get the total area of the shapes");
System.out.println("(3) Show information of the shapes");
System.out.println("(4) Quit");
System.out.println("Choice : ");
choice = scan.nextInt();
if (choice == 1)
{
System.out.println("enter the type of the shape");
kindofshape = scan2.nextLine();
if(kindofshape == "circle")
{
System.out.println("enter the radius");
radius = scan.nextInt();
}
if(kindofshape == "rectangle")
{
System.out.println("enter the width");
width = scan.nextInt();
System.out.println("enter the height");
height = scan.nextInt();
}
if(kindofshape == "square")
{
System.out.println("enter the width");
side = scan.nextInt();
}
}
}while(choice != 4);
}
}