Converting String to Char with If/Else Statement : <p>I'm really new to programming and I've been searching for days for a solution to this lab I'm working on. The lab is pretty simple and I believe I have the logic down, however when executing my code, I'm not getting the desired results. The program asks for input of three integers and one character. If the character is an 'S' the program will print the sum of the first 3 integers, if the character is a 'P,' the product, 'A,' the average, and any other character prints an error.</p>

<p>Below is my code. It asks for three integers and a character but the result is always an Error, even if i type in an 'S,' 'P,' or 'A.'</p>

<p>Any help would be greatly appreciated.</p>

<p>Thanks,
Joe</p>

<pre><code>    int n1, n2, n3;
    String numberFromKB;
    String charFromKB;
    Scanner keyboard = new Scanner (System.in);

    numberFromKB = JOptionPane.showInputDialog("Enter the first number.");
    n1 = Integer.parseInt(numberFromKB);

    numberFromKB = JOptionPane.showInputDialog("Enter the second number.");
    n2 = Integer.parseInt(numberFromKB);

    numberFromKB = JOptionPane.showInputDialog("Enter the 3rd number.");
    n3 = Integer.parseInt(numberFromKB);

    charFromKB = JOptionPane.showInputDialog(null, "Enter a character:");
    if (charFromKB = "s")
    {
        System.out.println("Sum of integers is: " + n1 + n2 + n3);
    }
    else if (charFromKB = "p")
    {
        System.out.println("Product of integers is: " + n1 * n2 * n3);
    }
    else if (charFromKB = "a")
    {
        System.out.println("Average of integers is: " + ((n1 + n2 + n3)/3f));
    }
    else 
    {
        System.out.println("ERROR!");
    }

}
</code></pre>

<p>}</p>
