Skip to content

Instantly share code, notes, and snippets.

@A-J-C
Created September 5, 2013 19:42
Show Gist options
  • Save A-J-C/6455122 to your computer and use it in GitHub Desktop.
Save A-J-C/6455122 to your computer and use it in GitHub Desktop.
This is for AdvancedJSCoders from Codecademy. This is the code for the challenge in Java and works when run in eclipse.
import java.util.Scanner;
public class TowerOfRandomness {
public static void main(String[] args) {
System.out.println("Welcome to Random Tower! \nWhat is the scope of your tower?: ");
int a = new Scanner(System.in).nextInt();
System.out.println("What is the height of your tower?: ");
int b = new Scanner(System.in).nextInt();
System.out.println("Ok. Generating a tower of 4 numbers between 1 and "+a+"...\n");
for(int i=0;i<b;i++){System.out.println((int) Math.floor(Math.random()*a+1));}
System.out.println("Tada!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment