Here I am up way to late trying to get all my semi-colons to behave.
The problem is: user enters name to search for in a dialog box.
I need to use a flag controlled while loop with a compound conditional expression
that utilizes the boolean variable found and the scanner method hasNext
to search through a local file and return the price(which is on the next line after the item in the file).
I get the general idea; that I need a while expression that matches the user input to each line in the
local file and if it returns false goes through the loop again till it matches. But I'm stuck.
After a couple of hours typing and deleting
and moving things around and looking in my books
and online......this is all I have:
It is probably obvious that this is not working.
It seems like there are a few concepts I dont have a grip on.
I would appreciate a shove in the right direction, gentle or otherwise.
Thanks for your time.
bill
The problem is: user enters name to search for in a dialog box.
I need to use a flag controlled while loop with a compound conditional expression
that utilizes the boolean variable found and the scanner method hasNext
to search through a local file and return the price(which is on the next line after the item in the file).
I get the general idea; that I need a while expression that matches the user input to each line in the
local file and if it returns false goes through the loop again till it matches. But I'm stuck.
After a couple of hours typing and deleting
and moving things around and looking in my books
and online......this is all I have:
Code:
Scanner fr = new Scanner(new FileReader("invoice.dat"));
double t = 0;
String u = null;
String usrIn;
Icon Q = new ImageIcon("Q_icon.jpg");
JLabel Qjl = new JLabel("Please enter the name of the item you " +
"want information about...", Q, JLabel.CENTER);
usrIn = JOptionPane.showInputDialog(null, Qjl, "SUPER INVENTORY " +
"SEARCH FACILITATOR ©2006", JOptionPane.PLAIN_MESSAGE);
boolean found = (usrIn.equals(fr.hasNext()));
while(!found){
}
}
}
It is probably obvious that this is not working.
It seems like there are a few concepts I dont have a grip on.
I would appreciate a shove in the right direction, gentle or otherwise.
Thanks for your time.
bill