Sunday, April 13, 2014

Trying to get a string from user input
































































































































I trying to get this code to get user input instead of reading from a hardcoded array. I'm getting compile errors while trying to get user input. Where did I go wrong? Here's some of the code:
































































































































































































Java Code:







































































































































// BubbleSort Java
// compile with: javac BubbleSort.java
// run with: java BubbleSort

import java.util.Arrays;
import java.io.*;
import java.util.Scanner;

public class BubbleSort {

public static void main(String args[]) {
String name;
int swapHolder;
int sizeOfArray = 0;
int pass = 1; //
int[] myArray;
//**write to array from file -- one int per line**
TextIO.put("Enter the filename from which you would like to read from: ");
name = TextIO.getln();
BufferedReader br = new BufferedReader(new FileReader(name));
int num;
while ((line = br.readLine()) != null) {
myArray[sizeOfArray] = num;
sizeOfArray ++;
}
br.close();





































































































































The errors:































































































































BubbleSort.java:18: error: cannot find symbol































































































































TextIO.put("Enter the filename from which you would like to read from: ");































































































































^































































































































symbol: variable TextIO































































































































location: class BubbleSort































































































































BubbleSort.java:19: error: cannot find symbol































































































































name = TextIO.getln();































































































































^































































































































symbol: variable TextIO































































































































location: class BubbleSort































































































































BubbleSort.java:22: error: cannot find symbol































































































































while ((line = br.readLine()) != null) {































































































































^































































































































symbol: variable line































































































































location: class BubbleSort































































































































3 errors






























































































































































































No comments:

Post a Comment