-
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
-
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
-
Thanks! Greatly appreciated!
Similar Threads
-
By JavaEnthusiast in forum C++
Replies: 1
Last Post: 04-10-2009, 02:16 AM
-
Replies: 8
Last Post: 07-18-2006, 11:51 PM
-
Replies: 1
Last Post: 06-12-2006, 11:20 AM
-
Replies: 2
Last Post: 04-30-2006, 09:08 AM
-
By Mike Tsakiris in forum .NET
Replies: 11
Last Post: 10-04-2002, 05: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
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|