Last active
August 29, 2015 13:59
-
-
Save JorgeOlvera/10441069 to your computer and use it in GitHub Desktop.
This file contains hidden or 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.*; | |
import java.util.*; | |
public class RandomIntegerData { | |
public static void main(String [] args) throws IOException { | |
Scanner input = new Scanner(System.in); | |
Random randomnum = new Random(); | |
System.out.println("Enter highest value "); | |
int highvalue = input.nextInt(); | |
System.out.println("Enter # of integers per line "); | |
int perline = input.nextInt(); | |
System.out.println("Enter the total number of integers "); | |
int tCount = input.nextInt(); | |
System.out.println("Enter the file name "); | |
String filename = input.next(); | |
try{ | |
PrintWriter outputFile = new PrintWriter( | |
new BufferedWriter( | |
new FileWriter(filename))); | |
int cell = 0; | |
while(cell<tCount){ | |
for(int a=0; a<perline; a++) { | |
int num = randomnum.nextInt(highvalue); | |
outputFile.print(num + " "); | |
cell++; | |
} | |
outputFile.print("\n"); | |
} | |
outputFile.close(); | |
} catch (IOException e){ | |
System.err.println("IOException @" + e.getMessage()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment