Welcome to the Newschoolers forums! You may read the forums as a guest, however you must be a registered member to post.
Register to become a member today!
Guy or Girl? Im stumped.... (with pics)
Posts: 3675
-
Karma: 1,573
Guy or Girl?
That is all...
Posts: 726
-
Karma: 25
import Math.java;
public class Guyorgirl{
public Static void main(String[] args) {
int gender = Math.random() * 2;
if (gender == 1) {
system.out.println("Its a guy");
}
else {
system.out.println("its a girl");
}
}
Posts: 726
-
Karma: 25
anyone who can write in java will lol^
Posts: 692
-
Karma: 417
Posts: 726
-
Karma: 25
nah, it works, accept i forgot a bracket
Posts: 8280
-
Karma: 5,173
Posts: 8280
-
Karma: 5,173
first impression:
girl
upon investigation....
unknown
Posts: 3745
-
Karma: 177
i cant write java but i understand that your essentailly flipping a coin. thus lulz
Posts: 726
-
Karma: 25
^ shes wearing thin necklace, my bet is a chick
Posts: 3937
-
Karma: 678
import Math.java;
public class Lolwut {
protected String gender;
protected int sex;
public Lolwut(){
sex = (int) (Math.random()*3);
}
public String getGender(){
if (sex == 1) {
return "male";
} else if (sex == 2) {
return "female";
} else {
return "WTF?";
}
}
}
public class Guyorgirl extends Lolwut {
public Static void main(String[] args) {
boolean wtf = true;
Lolwut lw = new Lolwut();
gender = lw.getGender();
if (!wtf){
System.out.println(gender);
} else {
System.out.println("WTF?");
}
}
}
My code is more reusable than yours, ha-ha! You're a second-rate programmer, I am INVINCIBLE!
Posts: 3937
-
Karma: 678
WTF? NS you screwed my formatting! shift+f! shift+f!
Posts: 3937
-
Karma: 678
*triple post:
ctrl + shift + f
Posts: 2419
-
Karma: 74
It took me a while... But then a lol'd. You win.
Posts: 726
-
Karma: 25
mine too, where are those spaces i put in there?
Posts: 726
-
Karma: 25
and i dint want to take wuite this amount of time to do it, and never compiled it, but props to you if you actually made this run
Posts: 726
-
Karma: 25
would it be going too far if i made a program going all out using the java.util.scanner and shit to get the user to choose like heads or tails?
Posts: 3937
-
Karma: 678
I debated it, but decided just to rock it that way... but I don't think implementing a scanner would be all that tough. It'd just be sticking this into your code, and then setting the final printout with an if (dudeOrChick == ..... else setup
public int dudeOrChick;
Scanner scan = new Scanner();
System.out.println("Type /"1/" for dude, /"2/" for chick");
dudeOrChick = scan.nextInt();
Posts: 210
-
Karma: 28
Posts: 429
-
Karma: 149
Posts: 1075
-
Karma: 321
Posts: 13045
-
Karma: 18,290
All times are Eastern (-4)