Jump to content

Help please? (;

- - - - -

  • Please log in to reply
7 replies to this topic

#1
JessieGurl19

JessieGurl19

    Newbie

  • Members
  • Pip
  • 1 posts
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

#2
Norm

Norm

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 327 posts
Look at using the Random class to randomly pick the output.

#3
SirJames

SirJames

    Newbie

  • Members
  • PipPip
  • 27 posts
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
PicklishDoorknob

PicklishDoorknob

    Learning Programmer

  • Members
  • PipPipPip
  • 86 posts
Easiest way:
(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
Sinipull

Sinipull

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 386 posts
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.
.

#6
PicklishDoorknob

PicklishDoorknob

    Learning Programmer

  • Members
  • PipPipPip
  • 86 posts

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.

...hey good idea. XD

#7
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java

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.

Haha, yea. I don't reply to such posts :D

#8
lethalwire

lethalwire

    while(false){ ... }

  • Members
  • PipPipPipPipPipPipPip
  • 748 posts
  • Programming Language:Java, PHP
  • Learning:Java, PHP

[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