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.

Page 1 of 2 12 LastLast
Results 1 to 25 of 26

Thread: Simple Java Poll - Please Help

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question 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.


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,155
    My Mood
    Hungover
    Thanks
    141
    Thanked 595 Times in 510 Posts

    Default 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.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Apr 2012
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Simple Java Poll - Please Help

    Quote Originally Posted by KevinWorkman View Post
    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
    Last edited by BurningSpirit; April 12th, 2012 at 11:57 AM.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,067
    Thanks
    47
    Thanked 2,146 Times in 2,119 Posts

    Default Re: Simple Java Poll - Please Help

    If you don't understand my answer, don't ignore it, ask a question.

  5. The Following 3 Users Say Thank You to Norm For This Useful Post:

    Gigggas (April 12th, 2012), KevinWorkman (April 12th, 2012), Tjstretch (April 12th, 2012)

  6. #5
    Junior Member
    Join Date
    Apr 2012
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Simple Java Poll - Please Help

    I think I should have posted this in the object oriented section

  7. #6
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,155
    My Mood
    Hungover
    Thanks
    141
    Thanked 595 Times in 510 Posts

    Default Re: Simple Java Poll - Please Help

    Quote Originally Posted by BurningSpirit View Post
    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
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  8. #7
    Junior Member
    Join Date
    Apr 2012
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default 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.

  9. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,067
    Thanks
    47
    Thanked 2,146 Times in 2,119 Posts

    Default 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.
    Last edited by Norm; April 12th, 2012 at 12:24 PM.
    If you don't understand my answer, don't ignore it, ask a question.

  10. The Following User Says Thank You to Norm For This Useful Post:

    BurningSpirit (April 12th, 2012)

  11. #9
    Junior Member
    Join Date
    Apr 2012
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Simple Java Poll - Please Help

    ok i'll post there, thanks

  12. #10
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,155
    My Mood
    Hungover
    Thanks
    141
    Thanked 595 Times in 510 Posts

    Default 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?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  13. #11
    Junior Member
    Join Date
    Apr 2012
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Simple Java Poll - Please Help

    I'm not actually stuck, I don't know where to begin in the coding.

  14. #12
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,067
    Thanks
    47
    Thanked 2,146 Times in 2,119 Posts

    Default 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.
    If you don't understand my answer, don't ignore it, ask a question.

  15. #13
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,155
    My Mood
    Hungover
    Thanks
    141
    Thanked 595 Times in 510 Posts

    Default Re: Simple Java Poll - Please Help

    Quote Originally Posted by BurningSpirit View Post
    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?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  16. #14
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,155
    My Mood
    Hungover
    Thanks
    141
    Thanked 595 Times in 510 Posts

    Default 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?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  17. #15
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,067
    Thanks
    47
    Thanked 2,146 Times in 2,119 Posts

    Default Re: Simple Java Poll - Please Help

    If you don't understand my answer, don't ignore it, ask a question.

  18. #16
    Junior Member
    Join Date
    Apr 2012
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default 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?

  19. #17
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,067
    Thanks
    47
    Thanked 2,146 Times in 2,119 Posts

    Default 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.
    If you don't understand my answer, don't ignore it, ask a question.

  20. #18
    Junior Member
    Join Date
    Apr 2012
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Simple Java Poll - Please Help

    This was the last thing I attempted.

    >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.
    Last edited by BurningSpirit; April 12th, 2012 at 03:36 PM.

  21. #19
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,067
    Thanks
    47
    Thanked 2,146 Times in 2,119 Posts

    Default 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
    If you don't understand my answer, don't ignore it, ask a question.

  22. #20
    Junior Member
    Join Date
    Apr 2012
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default 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.

  23. #21
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,067
    Thanks
    47
    Thanked 2,146 Times in 2,119 Posts

    Default Re: Simple Java Poll - Please Help

    reread post #12.
    Describe what you are trying to do in the code you posted.
    If you don't understand my answer, don't ignore it, ask a question.

  24. #22
    Junior Member
    Join Date
    Apr 2012
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Simple Java Poll - Please Help

    Each answer should have a number of votes

  25. #23
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,067
    Thanks
    47
    Thanked 2,146 Times in 2,119 Posts

    Default Re: Simple Java Poll - Please Help

    Ok, what are the steps the program must take to accomplish that?
    If you don't understand my answer, don't ignore it, ask a question.

  26. #24
    Junior Member
    Join Date
    Apr 2012
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default 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

  27. #25
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,067
    Thanks
    47
    Thanked 2,146 Times in 2,119 Posts

    Default 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?
    If you don't understand my answer, don't ignore it, ask a question.

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 2
    Last Post: December 19th, 2011, 12:49 PM
  2. Simple I/O Java Error
    By Prox in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 25th, 2011, 04:48 PM
  3. Java object help(should be simple)
    By Mirak in forum Object Oriented Programming
    Replies: 5
    Last Post: May 8th, 2010, 09:43 PM
  4. Simple game in Java
    By velop in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 27th, 2010, 05:04 AM