Need help designing java program - needs array, if/else, try/catch, while loop


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Need help designing java program - needs array, if/else, try/catch, while loop

  1. #1
    Join Date
    May 2010
    Posts
    2

    Smile Need help designing java program - needs array, if/else, try/catch, while loop

    I need assistance writing a program that contains an array, if/else statement, while loop, a try catch statement, and must create an object.

    A suggestion, or template would be greatly appreciated!
    The program needs to be something that is pretty basic, and that beginners could understand and write.
    No hangman please! haha

  2. #2
    Join Date
    May 2010
    Posts
    3
    Make a random joke generator.

    Use an array inside of the joke object for your jokes.

    Code:
    String jokes[] = {"Why did the chicken cross the road","joke 2","etc"};
    String answers[] = {"To get to the other side","joke 2 answer", "etc"};
    keep the arrays parrallel to make it easier.

    use a while loop to go through the array a random number of times and pick a joke kinda weird but neat.

    Code:
    while (jokeNum != randomNumberGenerated)
    {
      int Count++;
    }
    get and return the specified joke to the main class using intCount

    Code:
    jokes[intCount];
    answers[intCount];
    maybe keep track of the intCount used before and use an if else to make sure it doesnt send the same joke twice in a row.

    Code:
    if (oldIntCount == newIntCount)
      generateNewNumber();
    just an idea (:
    Ty

  3. #3
    Join Date
    May 2010
    Posts
    2
    Thanks! Greatly appreciated!

Similar Threads

  1. Replies: 1
    Last Post: 04-10-2009, 03:16 AM
  2. Replies: 8
    Last Post: 07-19-2006, 12:51 AM
  3. Replies: 1
    Last Post: 06-12-2006, 12:20 PM
  4. menu-driven java program (help please)
    By emasha in forum Java
    Replies: 2
    Last Post: 04-30-2006, 10:08 AM
  5. learning c# very confusing.
    By Mike Tsakiris in forum .NET
    Replies: 11
    Last Post: 10-04-2002, 06:32 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center