missing return statement need help!!
Code Java:
/**
* 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 [] choice, answer;
choice = new int[50];
answer = new int[50];
System.out.printf(" Welcome to Quiz Creator",s);
System.out.printf("What to do?",s);
System.out.printf("1]Specify number of question you want to do");
System.out.printf("2]Enter the question CATEGORY");
System.out.printf("3]Enter the QUESTION for each category");
System.out.printf("4]Enter the OPTION for each question");
System.out.printf("5]Provide the ANSWER for each question");
System.out.printf("6]Then your QUIZ GAME is ready to be play by your friend");
System.out.printf("Press any key to start the game..");
System.out.println();
input.nextLine();
System.out.println("How many question you want to create:");
choice[1]=input.nextInt();
System.out.println();
System.out.print('\u000C');
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('\u000C');
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.printf(choice[3] + 1 +" ] ");
category[b]=input.nextLine();
choice[3]=choice[3]+ 1;
}
System.out.print('\u000C');
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('\u000C');
System.out.printf(" welcome to game quiz");
System.out.printf("Game rule; 1] select 1 topic");
System.out.printf("2] answer the mcq question");
System.out.printf("3] each correct answer will given 10 point");
System.out.printf("4] each incorrect answer will be deducted 10 point");
System.out.printf("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('\u000C');
}
}
Re: missing return statement need help!!
Please post the full text of the error message.
Add the return statement that the compiler is asking for,
Re: missing return statement need help!!
Re: missing return statement need help!!
sorry i didnt know that if it was same web site or link to this one
Re: missing return statement need help!!
It isn't, but you are wasting other people's time.
Just imagine you got a reply on the other site and a user here thinks about your problem to give you the same answer. It's inconsiderate and rude.
1 Attachment(s)
Re: missing return statement need help!!
the coding was ok but the is an error on missing return statement ... at the end of coding.
i did try to delete or add "}" but i give the same error..
i didnt know if it was related to boolean because we havent learn about boolean in school.
Attachment 1938
Re: missing return statement need help!!
Did you add the missing return? Is the problem fixed now?
1 Attachment(s)
Re: missing return statement need help!!
not yet....i search google about missing return statement. there alot of which make me confusing..
Attachment 1939
Re: missing return statement need help!!
You don't seem to require a return statement for your code. You only have 1 method declared. I take it your using BlueJ. Just take a look at how you have declared your main method.
Re: missing return statement need help!!
which part of my coding..
Re: missing return statement need help!!
check over your code and make sure you have the basic outline for java typed out correctly. Remember that Java is case sensitive.
Re: missing return statement need help!!
You have "void" capitalized as "Void". Is it possibly seeing this as a type and trying to make you have a return statement? It should be all lowercase. Give that a shot and see what happens. Also noticed you dont have a space between "String[]" and "args". Other than that i see no blatant errors in your code.
Re: missing return statement need help!!
ok i try check my coding again...
--- Update ---
thnk for help..
Re: missing return statement need help!!
the typing error of Void instead of void is the problem. Your code will compile when you change it (I have BlueJ and it compiles). I don't think I could have directly told you as I have a mark against me for spood feeding and wasn't sure if I could or not.
Re: missing return statement need help!!
Is informing someone about a typo really spoon feeding? I have no problem of changing future advise. The line between spoon feeding and wasting people's time due to stupid errors is hard to define.
Re: missing return statement need help!!
Quote:
Originally Posted by
Chris.Brown.SPE
Is informing someone about a typo really spoon feeding? I have no problem of changing future advise. The line between spoon feeding and wasting people's time due to stupid errors is hard to define.
Thanks for letting me know. I just wasn't sure and didn't want to take the chance.
1 Attachment(s)
Re: missing return statement need help!!
Code Java:
/**
* 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];
String in;
System.out.printf(" Welcome to Quiz",s);
System.out.printf("What to do?",s);
System.out.printf("1]Specify number of question you want to do");
System.out.printf("2]Enter the question CATEGORY");
System.out.printf("3]Enter the QUESTION for each category");
System.out.printf("4]Enter the OPTION for each question");
System.out.printf("5]Provide the ANSWER for each question");
System.out.printf("6]Then your QUIZ GAME is ready to be play by your friend");
System.out.printf("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('\u000C');
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.printf(choice[3] + 1 +" ] ");
category[b]=input.nextLine();
choice[3]=choice[3]+ 1;
}
System.out.print('\u000C');
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('\u000C');
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;
while(rounds < numberofquiz)
{
System.out.println("please select a Category.");
System.out.println("Your current point is :" +Point);
{
for (int i=0; i <choice[1]; i++);
}
int choice[2]=userInput.nextInt();
System.out.println(question[pickcategory]);
System.out.println("1]" + option1[pickcategory]);
System.out.println("2]" + option2[pickcategory]);
System.out.println("3]" + option3[pickcategory]);
System.out.println("4]" + option4[pickcategory]);
System.out.println("what is your answer");
int playerans = userinput.nextInt();
if (playerans =answer[pickcategory]
{
System.out.print("\f");
System.out.println("your answer is correct");
System.out.println("the answer is:" + answer[pickcategory];
System.out.println();
Scorepoint += 10;
round += 1;
}
else
{
System.out.print("\f");
System.out.println("your answer is incorrect.");
System.out.println("the answer is :" + answer[pickcategory]);
System.out.println();
Scorepoint -=10;
rounds = NumberofQuestion;
}
playerans =0;
pickcategory = 0;
}
System.out.print("\f");
System.out.println("game Over");
System.out.println("your score:" + Scorepoint);
}
}
hi.. need help. here my full coding on game quiz i have a problem on( ']' expected) on bluej
here image:Attachment 1948
Re: missing return statement need help!!
The problem there is that you've already declared that array prior to this line. You dont need the word "int" before you access an array. When you get past that you have a lot of errors from missing parenthesis to undeclared variables.
1 Attachment(s)
Re: missing return statement need help!!
what it meant by " int cannot be dereferenced". i got this error.
Attachment 1952
Re: missing return statement need help!!
Quote:
int cannot be dereferenced
An int is not an object and does not have any methods you can call using an int variable. For example:
Code :
int x = 1;
x.size(); // int cannot be dereferenced
Re: missing return statement need help!!
ok..i try check again my coding..
Re: missing return statement need help!!
Quote:
check again my coding
If there are error messages, copy the full text and paste it here.
Otherwise please explain what the problem is.
1 Attachment(s)
Re: missing return statement need help!!
incompatible types -found int but expected boolen.. i did not know what does this meant..
Attachment 1954
Code Java:
/**
* 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];
String in;
System.out.printf(" Welcome to Quiz",s);
System.out.printf("What to do?",s);
System.out.printf("1]Specify number of question you want to do");
System.out.printf("2]Enter the question CATEGORY");
System.out.printf("3]Enter the QUESTION for each category");
System.out.printf("4]Enter the OPTION for each question");
System.out.printf("5]Provide the ANSWER for each question");
System.out.printf("6]Then your QUIZ GAME is ready to be play by your friend");
System.out.printf("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('\u000C');
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.printf(choice[3] + 1 +" ] ");
category[b]=input.nextLine();
choice[3]=choice[3]+ 1;
}
System.out.print('\u000C');
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('\u000C');
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[pickcategory]);
System.out.println();
Scorepoint += 10;
round += 1;
}
else
{
System.out.print("\f");
System.out.println("your answer is incorrect.");
System.out.println("the answer is :" + answer[pickcategory]);
System.out.println();
Scorepoint -=10;
rounds = NumberofQuestion;
}
playerans =0;
pickcategory = 0;
}
System.out.print("\f");
System.out.println("game Over");
System.out.println("your score:" + Scorepoint);
}
}
here my full coding on game quiz.
Re: missing return statement need help!!
Quote:
found int but expected boolen
The compiler found an int value/variable where it expected a boolean variable/value.
Can you post the full text of the error message that shows the statement with the error?
Here is a sample of a compiler error message:
Code :
TestSorts.java:138: cannot find symbol
symbol : variable var
location: class TestSorts
var = 2;
^
Re: missing return statement need help!!
How can I post compiler error. Is it same like post java coding...or the different methods. .