DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3

Hybrid View

  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, 02:16 AM
  2. Replies: 8
    Last Post: 07-18-2006, 11:51 PM
  3. Replies: 1
    Last Post: 06-12-2006, 11:20 AM
  4. menu-driven java program (help please)
    By emasha in forum Java
    Replies: 2
    Last Post: 04-30-2006, 09:08 AM
  5. learning c# very confusing.
    By Mike Tsakiris in forum .NET
    Replies: 11
    Last Post: 10-04-2002, 05:32 PM

Tags for this Thread

Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links