Hack Forums
[Java] Gay-O-Meter, did I make any mistakes? - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Java] Gay-O-Meter, did I make any mistakes? (/showthread.php?tid=4476102)



Gay-O-Meter, did I make any mistakes? - R҉eece҉ - Oct 4, 2014

So I decided to make a "Gay-O-Meter" because me and my brother always
joke around and call each other gay. I would like to know (this is my second
program), if I made any mistakes or should have done something differently.

It works at least haha.
// Note, this is for practice not usage.

Pastebin: http://pastebin.com/jtHMV7JP

Code
/*
* Gay-O-Meter
* Reece Leu
* 2014-10-04
*/
package gay.o.meter;
import java.util.Scanner;

public class GayOMeter {
    public static void main(String[] args) {
      Scanner getName = new Scanner(System.in);

      // Display welcome message.
      //Ask for users name.
      System.out.println("Welcome to Gay-O-Meter V2!");
      System.out.println("Please enter your name.");
      String userName = getName.nextLine();

      // Display a message.
      // Counts amount of letters in username.
      System.out.println("Calculating gayness...");
      int letterCount = userName.length();

      //Checks if userName equals Reece.
      // Checks is userName equals Logan.
      // Checks if letterCount is less than 1 or more than 10.
      // Finds % of how gay userName is depending on letterCount.
      if (userName.equals("Reece")) {
      System.out.println(userName + " is not gay.");
      } else if (userName.equals("Logan")) {
      System.out.println(userName + " is 400% gay.");
      } else if (letterCount > 10 || letterCount < 2) {
      System.out.println("ALLAH AKUBAR");
      } else {
      String howGay = null;
      switch (letterCount) {
            case 2: howGay = "10%";
            break;
            case 3: howGay = "20%";
            break;
            case 4: howGay = "30%";
            break;
            case 5: howGay = "40%";
            break;
            case 6: howGay = "50%";
            break;
            case 7: howGay = "60%";
            break;
            case 8: howGay = "70%";
            break;
            case 9: howGay = "80%";
            break;
            case 10: howGay = "80%";
            break;
            }
      System.out.println(userName + " is " + howGay + " gay.");
      }    
    }
}



* - Prince Gumball - Oct 4, 2014

Oh.. well ok then XD this seems pretty cool I guess :P XD


* - Kappa - Oct 4, 2014

Only problem I see is if they put in a name over 10 characters or under 2 characters it returns null, so you should make a default case.

EDIT:

[Image: SKhvDZH.png]
:(


* - IcYSeptember - Oct 4, 2014

You should use the levenshtein distance algorithm to determine how close the name is to your name.


* - R҉eece҉ - Oct 4, 2014

(Oct 4, 2014 11:23 PM)Kappa Wrote:  Only problem I see is if they put in a name over 10 characters or under 2 characters it returns null, so you should make a default case.

EDIT:

[Image: SKhvDZH.png]
:(

Haha yeah, I was going to make it so that if your name is over 10 character
you are allah akubar or something dumb. I just became tired.


* - ▁▂▃▄▅▆M1kep▆▅▄▃▂▁ - Oct 5, 2014

Only issue I see is more of a program flow "problem", you check if it's your name and then.say not gay if it's not your name then you start counting the letters.then you check if it's the other persons named then you decide how gay they are if they aren't Logan or whatever the name is.

So right now it's:
if
else
if
else

Rather than:
if
elseIf
else

I won't tell you the way to make it like that cause horny you can figure it out grim what I've said, if not just say so and I'll let ya know.:P


* - R҉eece҉ - Oct 5, 2014

(Oct 5, 2014 12:47 AM)▁▂▃▄▅▆M1kep▆▅▄▃▂▁ Wrote:  Only issue I see is more of a program flow "problem", you check if it's your name and then.say not gay if it's not your name then you start counting the letters.then you check if it's the other persons named then you decide how gay they are if they aren't Logan or whatever the name is.

So right now it's:
if
else
if
else

Rather than:
if
elseIf
else

I won't tell you the way to make it like that cause horny you can figure it out grim what I've said, if not just say so and I'll let ya know.:P

Ah yeah I see what you mean, I moved the countLetters above my name.
Ill update the script tomorrow. 2am haha.

Wow just looked up else if.
Thanks, I didnt know that was a thing.


* - T0SH1VA - Oct 5, 2014

HAHAHAHAAHAHAHAHA MAKING FUN OF THE SEXUALITY OF OTHERS IS SOOOO FUNNY!!! HAHAHAHAHAHAH!!!111111eleven!

oh dear... -.-


* - ObscureCoder - Oct 5, 2014

(Oct 5, 2014 04:49 AM)✹✹ T0SH1VA ✹✹ Wrote:  HAHAHAHAAHAHAHAHA MAKING FUN OF THE SEXUALITY OF OTHERS IS SOOOO FUNNY!!! HAHAHAHAHAHAH!!!111111eleven!

oh dear... -.-

"So I decided to make a "Gay-O-Meter" because me and my brother always
joke around and call each other gay."

Keyword: joke

OP, I know secret gay guys that call straight guys gay because they secretly like them.
o.O


* - Kappa - Oct 5, 2014

(Oct 5, 2014 06:50 AM)ObscureCoder Wrote:  OP, I know secret gay guys that call straight guys gay because they secretly like them.
o.O

You're so gay. wink wink nudge nudge


* - jmesthi - Oct 5, 2014

Lol very funny , why dont u start a website like xxx.homo.com ?


* - ▁▂▃▄▅▆M1kep▆▅▄▃▂▁ - Oct 5, 2014

(Oct 5, 2014 02:02 AM)ℝeece Wrote:  Ah yeah I see what you mean, I moved the countLetters above my name.
Ill update the script tomorrow. 2am haha.

Wow just looked up else if.
Thanks, I didnt know that was a thing.

Haha no worries :) we all learn someway


* - Sparta. - Oct 5, 2014

Oh wow, another 12 year old adolescent on this forum still using derogatory terms to sugarcoat homosexuals.

Not impressed.


* - ▁▂▃▄▅▆M1kep▆▅▄▃▂▁ - Oct 5, 2014

(Oct 5, 2014 09:52 AM)Sparta. Wrote:  Oh wow, another 12 year old adolescent on this forum still using derogatory terms to sugarcoat homosexuals.

Not impressed.

Wow look another user getting butt hurt over some words, it's a joke between two brothers and he posted it looking for code insight


* - ObscureCoder - Oct 5, 2014

(Oct 5, 2014 08:02 AM)Kappa Wrote:  You're so gay. wink wink nudge nudge*

Shut up, you're the gay one :) :P
blushes like a fag *