Hii (: Im trying to make a program that will randomly say yes no or maybe, kinda like a magic 8ball. But im stuck at the beggining :( Do you have any tips?
Thanks!
Jessie XOXOXOXOXOXO
7 replies to this topic
#1
Posted 18 February 2012 - 03:15 PM
|
|
|
#2
Posted 18 February 2012 - 05:01 PM
Look at using the Random class to randomly pick the output.
#3
Posted 18 February 2012 - 05:13 PM
This has no GUI and is in if you could say the simplest form you could code it (just giving you an idea lulz here's the code:p
import java.util.Random;
public class random {
public static void main(String args[]){
Random luckyball = new Random();
int num;
num = luckyball.nextInt(4);
if (num== 1) {
System.out.println("The lucky ball says....YES");
} else if (num == 2) {
System.out.println("The lucky ball says....NO");
} else if (num == 3) {
System.out.println("The lucky ball says....MABEY");
}
}
}
hope this help :P you abit
Edited by Alexander, 19 February 2012 - 07:57 PM.
[code]here[/code] tags
#4
Posted 21 February 2012 - 07:31 AM
Easiest way:
(sorry for lack of indentation, made this directly in the replybox)
(sorry for lack of indentation, made this directly in the replybox)
class MagicEightBall {
public static void main(String[] args) {
int result = (int) (Math.random() * 3);
switch(result) {
case 0:
System.out.println("Yes");
break;
case 1:
System.out.println("No");
break;
case 2:
System.out.println("Maybe");
break;
}
}
}
#5
Posted 21 February 2012 - 08:41 AM
I read it somewhere...
Step 1. Register with random girl name
Step 2. Write your programming problem in pink font
Step 3. Finish with Jessie/Jenny XOXOXO.
Step 4. Collect all the programs.
Step 1. Register with random girl name
Step 2. Write your programming problem in pink font
Step 3. Finish with Jessie/Jenny XOXOXO.
Step 4. Collect all the programs.
#6
Posted 21 February 2012 - 09:34 AM
Sinipull said:
I read it somewhere...
Step 1. Register with random girl name
Step 2. Write your programming problem in pink font
Step 3. Finish with Jessie/Jenny XOXOXO.
Step 4. Collect all the programs.
Step 1. Register with random girl name
Step 2. Write your programming problem in pink font
Step 3. Finish with Jessie/Jenny XOXOXO.
Step 4. Collect all the programs.
...hey good idea. XD
#7
Posted 21 February 2012 - 10:09 AM
Sinipull said:
I read it somewhere...
Step 1. Register with random girl name
Step 2. Write your programming problem in pink font
Step 3. Finish with Jessie/Jenny XOXOXO.
Step 4. Collect all the programs.
Step 1. Register with random girl name
Step 2. Write your programming problem in pink font
Step 3. Finish with Jessie/Jenny XOXOXO.
Step 4. Collect all the programs.
Haha, yea. I don't reply to such posts :D
#8
Posted 21 February 2012 - 03:52 PM
[SIZE=5][COLOR="#EE82EE"]System.out.println("yes no or maybe, kinda like a magic 8ball. But im stuck at the beggining Do you have any tips?
\n\n
Thanks!\n
Jessie XOXOXOXOXOXO");[/COLOR][/SIZE]
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









