-
February 27th, 2013, 02:01 AM
#1
java gui if statment help
I'm finishing up my code to my java program and its basically going to read questions from the array, ask user for the answer(a, b, c, or d). Then I'm going to make it calculate number wrong and right. I'm stuck on the part where my if statement only displays my else case "wrong". Here's the code thanks
Code:
import javax.swing.JOptionPane;
import java.text.DecimalFormat;
/**
This program is a guiquiz
*/
public class GuiQuiz
{
public static void main(String[] args)
{
String[] questions = { "What is science", "How many piers", "What is economics",
"What year is columbus" };
JOptionPane.showInputDialog(null, questions[0] + "\nA" + " metal," + "\nB. An art, \nC, Blue. \nD.Rockets");
parseInt;
if(questions[0].equalsIgnoreCase("a"))
{
System.out.println("Correct");
}
else
{
JOptionPane.showMessageDialog(null, "WRONG");
}
PS I am going to make another array with the correct answers so it can be easier calculating but, I want the first answer to be a but no matter what I put even a I get "WRONG"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|