The code I have so far is:
public class Project4 {
public static void main (String[] args) throws IOException {
final double OUNCES_PER_POUND = 16.0;
double pricePerPound;
double weightOunces;
double weightPounds;
double totalPrice;
String itemName;
Scanner fileScan = new Scanner(new File(args[0]));
NumberFormat money = NumberFormat.getCurrencyInstance();
DecimalFormat fmt = new DecimalFormat("0.00");
// Missing code that reads variables from text file goes here
weightPounds = weightOunces / OUNCES_PER_POUND;
totalPrice = weightPounds * pricePerPound;
System.out.println("Item: " + itemName);
System.out.println("Unit Price: " + money.format(pricePerPound));
System.out.println("Weight: " + fmt.format(weightPounds) + " pounds");
System.out.println("TOTAL: " + money.format(totalPrice));
}
}
What I'm trying to do is figure out how to pull the variables from a text file. The file must be declared as an argument in the command line which is why the header is set up as it is. The text file is basically the three variables I need, each on a separate line.
I was hoping that someone give me a hint or point me to some info on what I need to do to set up the variables so that I can declare each line from the text file as it's own separate variable.