Hey all, this is my first post and its nice to meet you all.
I appreciate all your help.
I have most of my program done already, but I'm having some problems with input and output files. There are 2 files of each. Lab4Input1.txt and 2 and Lab4Output1.txt and 2. The problem I'm having is selecting which file a user picks.
The code is as follows for what I'm having issues with:
Scanner keyIn = new Scanner(System.in); //assigns "keyIn" to keyboard
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int fileNum;
String inName;
String outName;
boolean inputBad = true;
do
{
System.out.print("Please enter file number, 1 or 2 > ");
fileNum = keyIn.nextInt( );
if (fileNum == 1 || fileNum == 2);
boolean inputBad = false;
}
while (inputBad = true);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (fileNum == 1)
{
Scanner inName = new Scanner(new FileReader("Lab4Input1.txt"))
PrintWriter outName = new PrintWriter("Lab4Output1.txt");
}
else
{
inName = "Lab4Input2.txt";
outName = "Lab4Output2.txt";
}
The first part I don't understand, its what my teacher said, but I dont know what it means. Why do I need to the inputBad = false; stuff.
The second part is what I am really stuck on. A user is supposed to type in which file he wants to choose, 1 or 2. My problem is making the code for how it chooses which files to use.