hello everyone I have some code that is not giving the output that it should
Example when I use readInt or readDouble it not giving me the correct set of data I have in an external file the code is below and the data input is here
thanks in advance
19.99 12 Java T-shirt
9.99 8 Java Mug
import java.io.*;
public class readDatastream {
public static void main(String[] args) throws IOException {
// read it in again
DataInputStream in = new DataInputStream(new
FileInputStream("invoice1.txt"));
double price;
int unit;
String desc ="test";
double total = 0.0;
try {
while (true) {
price = in.readFloat();
in.readChar(); // throws out the tab
unit = in.readInt();
in.readChar(); // throws out the tab
desc = in.readLine();
System.out.println("You've ordered " + unit + " units of " +
desc + " at $" + price);
total = total + unit * price;
}
} catch (EOFException e) {
}
System.out.println("For a TOTAL of: $" + total);
in.close();
}
}