Copy the text of the compiler's error into the clipboard and paste it here on the forum.
The same as pasting java source code here: copy and paste.
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Copy the text of the compiler's error into the clipboard and paste it here on the forum.
The same as pasting java source code here: copy and paste.
If you don't understand my answer, don't ignore it, ask a question.
widowx (March 28th, 2013)
incompatible types -found int but expected boolen
Where is the source line that is causing that error?incompatible types -found int but expected boolen
The compiler found an int value/variable where it expected a boolean variable/value.
Look at the code where the error is, Find the int value and replace it with a boolean value.
If you don't understand my answer, don't ignore it, ask a question.
widowx (March 28th, 2013)
owh...now i get it..the problem is i get confused with my first part of coding to be apply with second part which is game quiz start.
the first part is store the question and answer.
--- Update ---
i get the point now...when compile there no syntax error
Class compiled - no syntax error
if i want to run the programm it give an error
java.lang.ArrayIndexOutOfBoundsException: 50 at state.main(state.java:161)
--- Update ---
here my full coding edited
/** * Write a description of class state here. * * @author (your name) * @version (a version number or a date) */ import java.util.*; import java.io.*; import java.util.Scanner; public class state { public static void main(String [] args)throws FileNotFoundException { Scanner input=new Scanner(System.in); String s =" "; String[] data, category, option,option2,option3,option4; data = new String [50]; category = new String[50]; option = new String [50]; option2 = new String [50]; option3 = new String [50]; option4 = new String [50]; int numq; int [] choice, answer; choice = new int[50]; answer = new int[50]; System.out.printf(" Welcome to Quiz",s); System.out.printf("What to do?",s); System.out.println("1]Specify number of question you want to do"); System.out.println("2]Enter the question CATEGORY"); System.out.println("3]Enter the QUESTION for each category"); System.out.println("4]Enter the OPTION for each question"); System.out.println("5]Provide the ANSWER for each question"); System.out.println("6]Then your QUIZ GAME is ready to be play by your friend"); System.out.println("Press any key to start the game.."); System.out.println(); System.out.println("How many question you want to create:"); choice[1]=input.nextInt(); System.out.println(); System.out.print("\f"); input.nextLine(); System.out.println("Please enter your question CATEGORY"); for (int a=0; a<choice[1];a++) { System.out.print(choice[2]+1+"] "); data[a]=input.nextLine(); choice[2]=choice [2] + 1; } System.out.print("\f"); System.out.println(); System.out.println("Please enter your Question"); for (int b=0; b<choice[1];b++) { System.out.println(); System.out.println(" Category: " + data[b]); System.out.println(choice[3] + 1 +" ] "); category[b]=input.nextLine(); choice[3]=choice[3]+ 1; } System.out.print("\f"); System.out.println(); System.out.println("Please enter your question option "); for (int c=0; c<choice[1];c++) { System.out.println(); System.out.println("question : " + category [c]); System.out.println(); System.out.println("1]"); option[c] = input.nextLine(); System.out.println("2]"); option2[c] = input.nextLine(); System.out.println("3]"); option3[c] = input.nextLine(); System.out.println("4]"); option4[c] = input.nextLine(); System.out.println(); System.out.println("please set the answerto this question"); System.out.print("the answer is "); answer[c]= input.nextInt(); input.nextLine(); System.out.println(); } System.out.println("your quiz game is now ready...press the enter to start "); input.nextLine(); System.out.print("\f"); System.out.println(" welcome to game quiz"); System.out.println("Game rule; 1] select 1 topic"); System.out.println("2] answer the mcq question"); System.out.println("3] each correct answer will given 10 point"); System.out.println("4] each incorrect answer will be deducted 10 point"); System.out.println("5] the game will be over once your answer the question wrongly"); System.out.println(); System.out.printf(" press the enter key to start the game..."); input.nextLine(); System.out.print("\f"); int Scorepoint= 0; int rounds =0; int c=50; while(rounds < choice[1]) { System.out.println("please select a Category."); System.out.println("Your current point is :" +Scorepoint); { for (int i=0; i <choice[1]; i++); } choice[2]=choice[1]; System.out.println(data); System.out.println("1]" + option); System.out.println("2]" + option2); System.out.println("3]" + option3); System.out.println("4]" + option4); System.out.println("what is your answer"); int playerans = choice[2]; if (playerans<=answer[c]) { System.out.print("\f"); System.out.println("your answer is correct"); System.out.println("the answer is:" + answer[c]); System.out.println(); Scorepoint += 10; rounds += 1; } else { System.out.print("\f"); System.out.println("your answer is incorrect."); System.out.println("the answer is :" + answer[c]); System.out.println(); Scorepoint -=10; rounds = choice[2]; } playerans =0; } System.out.print("\f"); System.out.println("game Over"); System.out.println("your score:" + Scorepoint); } }
--- Update ---
what is this meant?
--- Update ---
I need help with above error and what should I do to fix...my coding
The index for an array at line 161 is past the end of the array. Look at the code at and before line 161 and see why the index got too big.java.lang.ArrayIndexOutOfBoundsException: 50
at state.main(state.java:161)
Remember array indexes range in value from 0 to the array length-1
That String is what is returned by a String array's toString() method.[Ljava.lang.String;@e3849c
If you want to print the contents of an Array use the Arrays class's toString() method:System.out.println("an ID "+ java.util.Arrays.toString(theArrayName));
If you don't understand my answer, don't ignore it, ask a question.
** * Write a description of class state here. * * @author (your name) * @version (a version number or a date) */ import java.util.*; import java.io.*; import java.util.Scanner; public class state { public static void main(String [] args)throws FileNotFoundException { Scanner input=new Scanner(System.in); String s =" "; String[] data, category, option,option2,option3,option4,playera; data = new String [50]; category = new String[50]; option = new String [50]; option2 = new String [50]; option3 = new String [50]; option4 = new String [50]; int numq; int[] choice, answer; choice = new int[50]; answer = new int[50]; System.out.printf(" Welcome to Quiz",s); System.out.printf("What to do?",s); System.out.println("1]Specify number of question you want to do"); System.out.println("2]Enter the question CATEGORY"); System.out.println("3]Enter the QUESTION for each category"); System.out.println("4]Enter the OPTION for each question"); System.out.println("5]Provide the ANSWER for each question"); System.out.println("6]Then your QUIZ GAME is ready to be play by your friend"); System.out.println("Press any key to start the game.."); System.out.println(); System.out.println("How many question you want to create:"); choice[1]=input.nextInt(); System.out.println(); System.out.print("\f"); input.nextLine(); System.out.println("Please enter your question CATEGORY"); for (int a=0; a<choice[1];a++) { System.out.print(choice[2]+1+"] "); data[a]=input.nextLine(); choice[2]=choice [2] + 1; } System.out.print("\f"); System.out.println(); System.out.println("Please enter your Question"); for (int b=0; b<choice[1];b++) { System.out.println(); System.out.println(" Category: " + data[b]); System.out.println(choice[3] + 1 +" ] "); category[b]=input.nextLine(); choice[3]=choice[3]+ 1; } System.out.print("\f"); System.out.println(); System.out.println("Please enter your question option "); for (int c=0; c<choice[1];c++) { System.out.println(); System.out.println("question : " + category [c]); System.out.println(); System.out.printf("1]"); option[c] = input.nextLine(); System.out.printf("2]"); option2[c] = input.nextLine(); System.out.printf("3]"); option3[c] = input.nextLine(); System.out.printf("4]"); option4[c] = input.nextLine(); System.out.println(); System.out.println("please set the answerto this question"); System.out.print("the answer is "); answer[c]= input.nextInt(); input.nextLine(); System.out.println(); } System.out.println("your quiz game is now ready...press the enter to start "); input.nextLine(); System.out.print("\f"); System.out.println(" welcome to game quiz"); System.out.println("Game rule; 1] select 1 topic"); System.out.println("2] answer the mcq question"); System.out.println("3] each correct answer will given 10 point"); System.out.println("4] each incorrect answer will be deducted 10 point"); System.out.println("5] the game will be over once your answer the question wrongly"); System.out.println(); System.out.printf(" press the enter key to start the game..."); input.nextLine(); System.out.print("\f"); int Scorepoint= 0; int rounds =0; int c=50; int playerans=0; while(rounds < choice[1]) { int Noq; System.out.println("please select a Category."); for (int a=0; a<choice[1];a++) { System.out.println(" Category: " + data[a]); } System.out.println("Your current point is :" +Scorepoint); system.out.println; Noq = input.nextInt(); for (int i=0; i <choice[1]; i++){ choice[i]=choice[3]; System.out.println(choice[1]); System.out.println("1]" + option); System.out.println("2]" + option2); System.out.println("3]" + option3); System.out.println("4]" + option4); System.out.println("what is your answer"); answer[c] = input.nextInt(); if (answer[c] == choice[i]) { System.out.print("\f"); System.out.println("your answer is correct"); System.out.println("the answer is:" + answer[c]); System.out.println(); Scorepoint += 10; rounds += 1; } else { System.out.print("\f"); System.out.println("your answer is incorrect."); System.out.println("the answer is :" + answer[c]); System.out.println(); Scorepoint -=10; rounds = choice[2]; } playerans =0; } System.out.print("\f"); System.out.println("game Over"); System.out.println("your score:" + Scorepoint); } } }
i got a 'statement error'..
can u help abit how to fix or hint..
Please copy the full text of the error message and paste it here.i got a 'statement error'..
If you don't understand my answer, don't ignore it, ask a question.
Thanks for helping me with coding. . Now my problem solved