How do you use an if and else statement with a string? I'm trying to do this
I ran it in debug mode and it displays the first dialog window but then it stops at status = keyboard.nextLine();. It doesn't continue to run the program after that. Help! Thank you!Code:
import javax.swing.JOptionPane;
import java.util.Scanner;
public class Tax_Calculations
{
public static void main(String []args)
{
String status, income;
double INCOME;
Scanner keyboard = new Scanner(System.in);
JOptionPane.showInputDialog("Please state your marital status. (SINGLE or MARRIED)");
status = keyboard.nextLine();
if (status == "SINGLE"){
JOptionPane.showInputDialog("What is your annual income?");
income = keyboard.nextLine();
INCOME = Double.parseDouble(income);
JOptionPane.showMessageDialog(null, INCOME);
System.exit(0);
}
else if (status == "MARRIED"){
System.exit(0);
}
}
}

