Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By quad64bit

Thread: Are these well written algorithms?

  1. #1
    dharav is offline Member
    Join Date
    Dec 2011
    Rep Power

    Question Are these well written algorithms?

    I have to write algorithms for my grade11 java class and i just wanted to know if these are good algorithms?

    1. Declare all variables needed.
    2. Declare all the arrays .
    3. Initialize arrays as needed.
    4. Initialize variables as needed.
    5. Prompt user for their name.
    6. Declare a if statement with 2 city outputs.
    7. Initialize array.
    8. For city chosen add the Sp and Hp to array.
    9. Calculate random number.
    10. Declare a if statement if the number even continue if odd press enter.
    11. Declare a for loop (villain greater than or = to 5) and go into loop if less than 5.
    12. Initialize a array with 1hp and 1 sp.
    13. Prompt user to press enter to hit.
    14. Subtract sp of players array by villains hp array.
    15. Prompt User with win screen.
    16. Add Sp chosen and add hp chosen at beginning of game.
    17. If more than 5 continue.
    18. Calculate random Number between 1-10.
    19. Initialize variable If number is 1 or 10 continue if not go in to loop and redo step ``18``.
    20. If 1 0r 10 Continue.
    21. Prompt User with screen to show the villain.
    22. Initialize a array with 24 hp and 6sp.
    23. Prompt to press enter to hit.
    24. Minus players sp from array by villains hp.
    25. Minus villains sp from array by players hp.
    26. If villain array value of hp is 0 or less continue or else if 1or more in hp repeat step ``23``.
    27. Prompt User with winning screen to Praise them.

  2. #2
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Rep Power

    Default Re: Are these well written algorithms?

    What exactly is the algorithm? And how are you looking to define 'good'?
    Eranga likes this.

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Colombo, Sri Lanka
    Blog Entries
    Rep Power

  4. #4
    stchman's Avatar
    stchman is offline Member
    Join Date
    Apr 2011
    Saint Louis, Missouri
    Rep Power

    Default Re: Are these well written algorithms?

    Write the algorithm first before we can tell you if they are well written. It looks like you have well organized ideas so far.
    If you aren't programming in Java, well that's just too bad.
    I'd rather be using Ubuntu.

Similar Threads

  1. Sorting Algorithms
    By fam2315 in forum New To Java
    Replies: 7
    Last Post: 07-27-2011, 05:55 AM
  2. Threaded algorithms
    By TerTer in forum Threads and Synchronization
    Replies: 0
    Last Post: 04-20-2010, 02:58 PM
  3. Compression Algorithms
    By kishan in forum Advanced Java
    Replies: 1
    Last Post: 09-21-2009, 09:13 AM
  4. genetic algorithms
    By nurfadhillah in forum Advanced Java
    Replies: 1
    Last Post: 10-19-2008, 04:13 PM
  5. Iterative Algorithms
    By Zosden in forum Algorithms
    Replies: 1
    Last Post: 07-05-2008, 06:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts