So I am trying to make a simple calculator using java code. I want it to ask the user what he/she wants to do, then based on the answer, execute the code. For some reason it just closes after asking "Is there anything else you want to do". Can anyone help?
Here's the code:
import java.util.Scanner; public class calculator { public static void main(String[] args ) { Scanner user_input = new Scanner(System.in); System.out.print("Is there anything you would you like to do?"); if(user_input.next() .equals("no")) {System.out.println("Ok thanks for trying this program");} if(user_input.next() .equals("yes")) {System.out.println("Ok what would you ike to do?");} if(user_input .equals("multiply")) { double firstNo, secondNo; System.out.println("Please input the first number "); firstNo = Double.parseDouble(user_input.next()); System.out.println("Please input the second number "); secondNo = Double.parseDouble(user_input.next()); double finalProduct= firstNo * secondNo; System.out.println("The final product is "+finalProduct ); System.out.println("Is there anything else you want me to do?"); if(user_input.next() .equals("no")) {System.out.println("Ok thanks for trying this program");} } if(user_input.next() .equals("divide")) { double firstNo, secondNo; System.out.println("Please input the first number "); firstNo = Double.parseDouble(user_input.next()); System.out.println("Please input the second number "); secondNo = Double.parseDouble(user_input.next()); double finalProduct= firstNo / secondNo; System.out.println("The final product is "+finalProduct ); System.out.println("Is there anything else you want me to do?"); if(user_input.next() .equals("no")) {System.out.println("Ok thanks for trying this program");} } if(user_input.next() .equals("add")) { double firstNo, secondNo; System.out.println("Please input the first number "); firstNo = Double.parseDouble(user_input.next()); System.out.println("Please input the second number "); secondNo = Double.parseDouble(user_input.next()); double finalProduct= firstNo + secondNo; System.out.println("The final product is "+finalProduct ); System.out.println("Is there anything else you want me to do?"); if(user_input.next() .equals("no")) {System.out.println("Ok thanks for trying this program");} } } }