Tasks
-Write the correct code to open the provided file inventory.txt that contains the sales prices of store items in invetory.
-Calculate the total value of the inventory.
-Count the total number of entries in the inventory.
-Print the total value of the ineventory along with the number of items (number of entries) in a descriptive message to the screen.
-Print the average in a descriptive message to the screen.
-In addition, write this information to a file named processedInventory.txt
I have been working on this code and i am struggling...
this is what i have soo far. any input or tips would be greatly appreciated.
import java.util.*;
import java.io.*;
public class Lab14 {
public static void main(String[] args) throws FileNotFoundException {
// TODO Auto-generated method stub
File file = new File("inventory.txt");
Scanner reader = new Scanner(file);
double value = 0.0;
try{
while(reader.hasNext()){
value = reader.nextDouble();
}
}catch(InputMismatchException tim){
System.out.println("InputMismatch!!!!");
}
}
}