-
Simple Java Poll - Please Help
Hi, I work at a radio station and recently I want to develop a easier way our viewers get in touch with us. One of the most popular features of a local radio station is the use of indicative opinion polls to reflect their listener’s opinions on current news items and events. The polls ask a question and then four responses. The listener selects the answer which they most favour. We use the polls and results in phone-in programmes to generate interest in certain programmes.
So anyways here's my problem; I want to create a basic poll.
For example -
Question - Which country out of the four would you want to go on holiday too?
Responses USA, Thailand, Greece, Italy
So basically what I'm trying to implement is when the program starts it will display an initial menu screen with the following set of options:
1. Display the current score for each possible response.
2. Vote
3. Quit the program.
Display an error message if an invalid response is entered.
If the user selects option two, the program will display the question and the four possible responses. The user will then enter a response and the response will be recorded in the program. Again display an error message if the response is invalid.
The thing I'm trying to do is create one class with the following data:
Survey question
Four possible responses
The current score for each response
It should contain the following methods:
A setter and getter for the survey question
Setters and getters for each of the responses
addVotes, which will add one to the score for the specified response.
It's been years since I've last done java and I really need some help, if anyone can point in the right way with the coding that would be great.
-
Re: Simple Java Poll - Please Help
Are you trying to do this as an applet? Or are you talking about, say, using jsp to display the quiz on a webpage? Or are you actually talking about javascript (which isn't java)?
I should point out that you might be reinventing the wheel here- I don't know what kind of website you have now, but I would predict that most packages (like wordpress, forums like these) have some kind of quiz feature pre-installed or at least available.
-
Re: Simple Java Poll - Please Help
Quote:
Originally Posted by
KevinWorkman
Are you trying to do this as an applet? Or are you talking about, say, using jsp to display the quiz on a webpage? Or are you actually talking about javascript (which isn't java)?
I should point out that you might be reinventing the wheel here- I don't know what kind of website you have now, but I would predict that most packages (like wordpress, forums like these) have some kind of quiz feature pre-installed or at least available.
Applet, possibly.
At this stage I'm just trying to construct the code for the Poll on Java e.g Jeditor/Eclipse
-
Re: Simple Java Poll - Please Help
-
Re: Simple Java Poll - Please Help
I think I should have posted this in the object oriented section
-
Re: Simple Java Poll - Please Help
Quote:
Originally Posted by
BurningSpirit
I think I should have posted this in the object oriented section
That really wouldn't change the response you're getting. We need to know more background to answer your question. Actually, I'm not even sure what your question is. You've posted your requirements, but not where you're stuck. If you don't know where to start, the only thing I can really tell you is to consult the basic tutorials: The Java™ Tutorials
-
Re: Simple Java Poll - Please Help
I need help with the coding on Jedit/Eclipse; although I think I may have gotten myself confused by posting in the Java section as the program I'm trying to make is object oriented and I'm using Jedit currently.
-
Re: Simple Java Poll - Please Help
If you need help with your IDE there is a section of the forum for that:
Java IDEs
If you have java programming problems, you can post them here.
-
Re: Simple Java Poll - Please Help
ok i'll post there, thanks
-
Re: Simple Java Poll - Please Help
The IDE forum is for posting questions specific to an IDE- how to export a Jar in eclipse, for example. Problems about code are not inherently about an IDE, because you'd have the same problem in jEdit, eclipse, notepad, whatever. I've deleted your post in the IDE section.
You've posted your requirements, but you haven't actually said where you're stuck. What have you tried? What do you have so far?
-
Re: Simple Java Poll - Please Help
I'm not actually stuck, I don't know where to begin in the coding.
-
Re: Simple Java Poll - Please Help
Do you have a design for what you want the program to do? If the design is at a high level, you need to take each feature or step in the high level design and make a detailed design for how to do it.
When you have the details worked out, THEN you would start coding. Don't start coding without a detailed design.
-
Re: Simple Java Poll - Please Help
Quote:
Originally Posted by
BurningSpirit
I'm not actually stuck, I don't know where to begin in the coding.
Like I said, I suggest you check out the tutorial I linked. Can you write hello world?
-
Re: Simple Java Poll - Please Help
Please stop posting duplicate copies of this same question in multiple forums. You aren't going to get any answers that are different from the advice I already gave you, and it's just going to confuse people trying to help you. I deleted your other post, again.
Did you read the tutorials? Did you try to write any code at all? What have you tried? Where are you stuck?
-
Re: Simple Java Poll - Please Help
-
Re: Simple Java Poll - Please Help
Yes I've tried, if it worked I wouldn't of been coming on here asking for help...
Hey Norm are you actually going to try to help or just fish out topics I've created?
-
Re: Simple Java Poll - Please Help
Ask your questions about the problems you are having writing a java program. So far there have not been anything specific asked that can be answered.
Post the code that you are having problems with.
-
Re: Simple Java Poll - Please Help
This was the last thing I attempted.
Code java:
>public class HolidayPoll{
public static void main(String args[]){
int holidayVotes;
int votes[] = new int [3]; //Array to hold 4 votes
USA[0] = 56;
Greece[1] = 45;
Thailand[2] = 33;
Italy[3] = 34;
arrayElement = Dialogs.integerInput("Which Holiday do you want to show?"};
Dialogs.outputMessage("The amount of votes this Holiday has is: " + holidayVotes[arrayElement]);
//print all element
for (int i = 0; i < 0; i++{
System.out.println("Holiday Votes (" + i +") is: + Holiday Votes[i});
}
System.out.println("No more holiday votes");
}
}<
Like I said in my first post, I haven't done Java in a long time.
-
Re: Simple Java Poll - Please Help
What are you questions?
Post the full text of any error messages here.
Please Edit your post and wrap your code with[code=java]<YOUR CODE HERE>[/code] to get highlighting
-
Re: Simple Java Poll - Please Help
I'm pretty sure the whole code is wrong considering I've been looking at tutorials and other codes to try and piece it together.
-
Re: Simple Java Poll - Please Help
reread post #12.
Describe what you are trying to do in the code you posted.
-
Re: Simple Java Poll - Please Help
Each answer should have a number of votes
-
Re: Simple Java Poll - Please Help
Ok, what are the steps the program must take to accomplish that?
-
Re: Simple Java Poll - Please Help
Each answer should have a number set to it where later every time the program runs another vote can be added to it.
The basis of the program is posted in the original OP
-
Re: Simple Java Poll - Please Help
Now you need to define the steps the program must take to do the desired task.
For instance:
define an array to hold the count of answers for each question.
What's next?