Hello
I am a newbie in java so now i just write codes with dialogs and JOptionPane .. like this so it's easy codes. So i want to write a program like this;

Application will use only Dialog Boxes. Frames are not allowed to use.
Application should ask eight questions to user. You can find the questions and answer
at the end of the document.
Dialog boxes should use a different icon .
At the end of the quiz, the application should give information about:
• how many questions have been answered?
• how many of them are correct?
• How many of them are incorrect?
• What is the success percentage?

User should be able to give up quiz at any time by pressing red cross button on the
right top corner of the dialog box (close button for window). In this case, the
application should prompt the user if s/he really wants to give up. If s/he choose YES
button then the application should provide the information below. Otherwise, the
quiz should continue.


Quiz Questions and Answers
What shortcut we use for importing objects in "Eclipse" IDE?
A-) CTRL + O
B-) ALT + O
C-) CTRL + SHIFT + O
D-) ALT + SHIFT + O
What shortcut we use to compile & run a source code in "Eclipse" IDE?
A-) ALT + SHIFT + X and J
B-) CTRL + SHIFT + J and X
C-) CTRL + ALT + J and Q
D-) ALT + CTRL + Q
What is the current version for "JDK" Kit?
A-) JDK 1.4 Update 1
B-) JDK 1.5 Update 10
C-) JDK 1.6 Update 9
D-) JDK 1.6 Update 3
Which option is not an IDE "Integrated Development Environment"?
A-) Eclipse
B-) JIDE
C-) Jcreator
D-) NetBeans
Which option is not a feature of JAVA?
A-) Cross Platform
B-) Memory Management
C-) Easy GUI Creation
D-) Object - Oriented Programming
What is the name of the component that we use to create dialog box?
A-) JtextField
B-) JOptionPane
C-) JtextPanel
D-) JTextArea
What should be the name of the class, if the file name is Hello.java?
A-) _HeLLO
B-) hello
C-) HELLO
D-) Hello

Thanx for All Java Coders
Please Help! :(

Recommended Answers

All 9 Replies

We are not just simply going to do your homework. Tell us your answers, and we might, I repeat might tell you if you're right.

To be more precise, post your code which you should have by now at least started. Point where you running into troubles and we will see what can be done about it

No, not just post your code, look a little closer at the OP, and you will see a list of multiple choice questions. He really just wants his entire homework/test done for him. He has no desire to do it himself, at all.

;-)

Yes you are right!you are not going to do my homework for me. So i don't what this just help. So i am not a student you can belive if u want it's your problem.

i allready wrote codes which i search and convert for me but i didn't understand it wasn't work but never give a error..

import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
 
class Quiz
{
	public static String [] question;			
	public static String [][] answers;			
	public static String [] actualAnswers;		
	public static int qCount = 0;			
	public static int SIZE = 8;				
	public static int score = 0;			
		
	public static String [] loadQuestions()
	{
		String [] q = new String [SIZE];
		
		
		q[0] = "What shortcut we use for importing objects in \"Eclipse\" IDE? ";
		q[1] = "What is the current version for \"JDK\" Kit?";
		q[2] = "Which is the 50th state of the US?";
		q[3] = "Which option is not an IDE \"Integrated Development Environment\"?";
		q[4] = "Which option is not a feature of JAVA?";
		q[5] = "What is the name of the component that we use to create dialog box?";
		q[6] = "What should be the name of the class, if the file name is Hello.java? ";
		q[7] = "Which one is not a method of JOptionPane class?";
		
		return q;
	}
	
	public static String [][] loadAnswers()
	{
		String [][] a = new String [SIZE][];
		
		
		a[0] = new String [] { "A-) CTRL + O", "B-) ALT + O", "C-) CTRL  + SHIFT + O ", "D-) ALT + SHIFT + O " };
		a[1] = new String [] { "A-) ALT + SHIFT + X and J", "B-) CTRL + SHIFT + J and X", "C-) CTRL + ALT + J and Q ", "D-) ALT + CTRL + Q " };
		a[2] = new String [] { "A-) JDK 1.4 Update 1", "B-) JDK 1.5 Update 10", "C-) JDK 1.6 Update 9 ", "D-) JDK 1.6 Update 3 " };
		a[3] = new String [] { "A-) Eclipse", "B-) JIDE ", "C-) Jcreator", "D-) NetBeans" };
		a[4] = new String [] { "A-) Cross Platform ", "B-) Memory Management", "C-) Easy GUI Creation", "D-) Object - Oriented Programming"};
		a[5] = new String [] { "A-) JtextField ", "B-) JOptionPane ", "C-) JtextPanel ", "D-) JTextArea" };
		a[6] = new String [] { "A-) _HeLLO ", "B-) hello", "C-) HELLO", "D-) Hello" };
		a[7] = new String [] { "A-) showInputDialog", "B-) showOptionDialog", "C-) showInformDialog", "D-) showMessageDialog " };
		
		return a;
	}
	
	public static String [] correctAnswers()
	{
		String [] ca = new String [SIZE];
		

		ca[0] = "C-) CTRL  + SHIFT + O ";
		ca[1] = "A-) ALT + SHIFT + X and J";
		ca[2] = "D-) JDK 1.6 Update 3 ";
		ca[3] = "B-) JIDE";
		ca[4] = "C-) Easy GUI Creation";
		ca[5] = "B-) JOptionPane ";
		ca[6] = "D-) Hello";
		ca[7] = "C-) showInformDialog";
			
		return ca;
	}
	
	public static String askOne ( int item, String [] ans )
	{
		new ImageIcon("icon.png");
		Object userAnswer;
		userAnswer = JOptionPane.showInputDialog( null, question[item],
				"Question " + ++qCount,
				JOptionPane.QUESTION_MESSAGE,
				null,
				answers[item],
				answers[item][0] );
		
	
		if ( userAnswer == null )
		{
			System.exit( 0 );
		}
		
		
		for ( int k = 0; k < SIZE; k++)
		{
			
			if ( userAnswer == ans[k] )
			{
				score++;
			}
		}
		return userAnswer.toString();
	}
	  
public static void main(String args[])
{
	question = loadQuestions();
	answers = loadAnswers();
	actualAnswers = correctAnswers();
	
	
	int lastQuestion = question.length - 1;
	while ( lastQuestion > 0 )
	{
		int r = (int)(question.length * Math.random());
		question[lastQuestion] = question[r];
		
		answers[lastQuestion] = answers[r];
		
		actualAnswers[lastQuestion] = actualAnswers[r];
	}
	
	int lastAnswer = answers.length - 1;
	for ( int l = 0; l < answers.length; l++ )
	{
		int ran = (int)(answers.length * Math.random());
		while ( lastAnswer > 0 )
		{
			answers[l][ran] = answers[l][lastAnswer];
			lastAnswer--;
		}
	}
	
	for (int k = 0; k < SIZE; k++)
	{
		System.out.println( askOne( k, actualAnswers ) );
	}
	JOptionPane.showMessageDialog( null, "Invalid entry!", "You got " + score + " answers correct!", JOptionPane.INFORMATION_MESSAGE );
}
}

i allready wrote codes which i search and convert for me but i didn't understand it wasn't work but never give a error..

What does it mean?
Is this your code ?

no it wasn't my code!

i wrote i was search and found in internet and convert for my application

i allready wrote codes which i search and convert for me but i didn't understand it wasn't work but never give a error..

thanx all us

Yes I did it;

All of my codes!

import javax.swing.JOptionPane;
import javax.swing.ImageIcon;

public class Quiz{

	static int kac = 8;
	
	
	 public static void main(String[] args) {
		 
		 
		 String soru[] = {
				"What shortcut we use for importing objects in 'Eclipse' IDE?",
				"What shortcut we use to compile & run a source code in 'Eclipse' IDE?",
				"What is the current version for 'JDK' Kit?",
				"Which option is not an IDE 'Integrated Development Environment'?",
				"Which option is not a feature of JAVA?",
				"What is the name of the component that we use to create dialog box?",
				"What should be the name of the class, if the file name is Hello.java?",
				"Which one is not a method of JOptionPane class?"
			};
			String cevap[][] = 
		        {
				{"A-) CTRL + O","B-) ALT + O","C-) CTRL + SHIFT + O","D-) ALT + SHIFT + O"},
				{"A-) ALT + SHIFT + X and J","B-) CTRL + SHIFT + J and X","C-) CTRL + ALT + J and Q","D-)ALT + CTRL + Q"},
				{"A-) JDK 1.4 Update 1","B-) JDK 1.5 Update 10","C-) JDK 1.6 Update 9","D-) JDK 1.6 Update 3"},
				{"A-) Eclipse","B-) JIDE","C-) JCreator","D-) NetBeans"},
				{"A-) Cross Platform","B-) Memory Management","C-) Easy GUI Creation","D-) Object - Oriented Programming"},
				{"A-) JtextField","B-) JOptionPane","C-) JtextPanel","D-) JTextArea"},
				{"A-) _HeLLO","B-) hello","C-) HELLO","D-) Hello"},
				{"A-) showInputDialog","B-) showOptionDialog","C-) showInformDialog","D-) showMessageDialog"}
			};
			int sonuc []={
					2,0,3,1,2,1,3,2
			};
				
			
			
				
				
				ImageIcon icon = new ImageIcon("icon.png");
				
				int topla =0;
				int soruno =0;
			int dogru = 0;
			int yanlis =0;
			int adet;
		
				int sordum;
				float dogruortalama=0,yes=0,no=0;

				for (int i=0; i<8; i++){
					
					adet = i+1;
				
			
				sordum = JOptionPane.showOptionDialog(null, soru[i], "Question " +adet, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, icon, cevap[i], cevap[i][0]);	
				
				 
				if (sordum ==-1){
					int exit=JOptionPane.showConfirmDialog(null,"Are you sure you want to give up quiz?","Quiz", JOptionPane.YES_NO_OPTION);
                    
					if (exit==JOptionPane.YES_OPTION){
						
					break;}

				} 
				else {  
					if (sordum == sonuc[i]) {
						yes = +1;
						dogru=dogru+1;
						} else {
							no=no+1;
							yanlis=yanlis+1;
							
						}
					}soruno= i+1;		
			}
				dogruortalama = (yes*100)/soruno;

		
		
				JOptionPane.showMessageDialog(
						null,"You Have Answered "+topla+" Question.\n"
						+dogru+" of them are correct.\n"+yanlis+" of them are incorrect.\n" +"Your Success Rate is =% "+dogruortalama ,
						"Results",JOptionPane.INFORMATION_MESSAGE);

					
				
			
	 }
}

Keep up good work...

PS: In future please be more specific about what you asking and source code is always good way to explain your problem

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.