12 |
- "use strict";(self.webpackChunkmy_application=self.webpackChunkmy_application||[]).push([[5087],{5087:(t,n,e)=>{e.r(n),e.d(n,{default:()=>i});const i='/*\n\tBasic Java example using FizzBuzz\n*/\n\nimport java.util.Random;\n\npublic class Example {\n\tpublic static void main (String[] args){\n\t\t// Generate a random number between 1-100. (See generateRandomNumber method.)\n\t\tint random = generateRandomNumber(100);\n\n\t\t// Output generated number.\n\t\tSystem.out.println("Generated number: " + random + "\\n");\n\n\t\t// Loop between 1 and the number we just generated.\n\t\tfor (int i=1; i<=random; i++){\n\t\t\t// If i is divisible by both 3 and 5, output "FizzBuzz".\n\t\t\tif (i % 3 == 0 && i % 5 == 0){\n\t\t\t\tSystem.out.println("FizzBuzz");\n\t\t\t}\n\t\t\t// If i is divisible by 3, output "Fizz"\n\t\t\telse if (i % 3 == 0){\n\t\t\t\tSystem.out.println("Fizz");\n\t\t\t}\n\t\t\t// If i is divisible by 5, output "Buzz".\n\t\t\telse if (i % 5 == 0){\n\t\t\t\tSystem.out.println("Buzz");\n\t\t\t}\n\t\t\t// If i is not divisible by either 3 or 5, output the number.\n\t\t\telse {\n\t\t\t\tSystem.out.println(i);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t\tGenerates a new random number between 0 and 100.\n\t\t@param bound The highest number that should be generated.\n\t\t@return An integer representing a randomly generated number between 0 and 100.\n\t*/\n\tprivate static int generateRandomNumber(int bound){\n\t\t// Create new Random generator object and generate the random number.\n\t\tRandom randGen = new Random();\n\t\tint randomNum = randGen.nextInt(bound);\n\n\t\t// If the random number generated is zero, use recursion to regenerate the number until it is not zero.\n\t\tif (randomNum < 1){\n\t\t\trandomNum = generateRandomNumber(bound);\n\t\t}\n\n\t\treturn randomNum;\n\t}\n}\n '}}]);
- //# sourceMappingURL=5087.js.map
|