Last active
August 29, 2015 14:01
-
-
Save resetter/5d090f0527cdb79127c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.PrintStream; | |
import java.io.IOException; | |
import java.io.File; | |
import java.util.Scanner; | |
import java.util.Random; | |
public class randInts | |
{ public static void main(String[] args) | |
{ try | |
{ PrintStream writer = new PrintStream( new File("randInts.txt")); | |
Scanner s = new Scanner(System.in); | |
System.out.print( "How many digits?: "); | |
int digits = s.nextInt(); | |
Random rand = new Random(); | |
for (int i = 0; i < digits; i++) { | |
int output = Math.abs((rand.nextInt(10))); | |
writer.print(output); | |
} | |
writer.close(); | |
} | |
catch(IOException e) | |
{ System.out.println("An error occured while trying to write to the file"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment