r/programminghelp • u/um_gato_gordo • Dec 17 '25
Java rate my fizzbuzz answer
Im learning trough a youtube tutorial, and this is my first time trying to solve it, ignore the random portuguese curse words as variable names
Also before anyone else says this inst fizzbuzz, in the video im watching it asked to print fizz if the input was divisible by 3, buzz if it was divisible by 5 (or the other way around, idr) if its divisible by both print fizzbuzz and if it inst divisible by neither return the input.
Scanner scanner = new Scanner(System.in);
int porra = 0;
int caralho = 0;
int asd = 0;
int cu;
cu=scanner.nextInt();
if (cu % 5 == 0) {caralho+=1;}
if (cu % 3 == 0) {porra+=1;}
if (caralho==1 && porra==1) {asd=1;}
else if (caralho==1 && porra==0) {asd=2;}
else if (caralho==0 && porra==1) {asd=3;}
else {asd=4;}
switch (asd) {
case 1:
System.out.println("fizzbuzz");
break;
case 2:
System.out.println("fizz");
break;
case 3:
System.out.println("buzz");
break;
case 4:
System.out.println(cu);Scanner scanner = new Scanner(System.in);
View all comments
Show parent comment
1
u/Eweer Dec 18 '25 edited Dec 18 '25
As a C++ programmer, it truthfully hurt my heart reading that someone guessed C++ while reading Java. /s or not?
This is the C++ version (literally transcribed line by line) of the code that OP posted: