1.) Prompt user for the file name to be created
2.) Collect sales data for 4-weeks from the user
3.) read the data into two-dimension array and do some calc.
How do I prompt a user for file name and create it? Here is the code I use, but not competely correct:
public static void readFile()
throws FileNotFoundException {
System.out.print("Enter file name and extension" );
String fileName = input.nextLine();
File inputFile = new File(fileName);
Scanner reader = new Scanner(inputFile);
while(reader.hasNext()){
store.add(reader.nextInt());
}
}
And how do I put all 4 weeks info in a nested for loop instead of having individual loops?
System.out.print("\nEnter WEEK 1 sales with spaces(e.g: 12 56 23........)"
+ " after each Daily Sales Numbers:");
int count=0;
for (int i=0; i <= 4; i++){
for(int j=0; i <= 7; j++){
week1 = input.nextInt();
count=0;
// System.out.print(week1 + " ");
}
input.nextLine();
System.out.println(count+"\n");
}
thanks!!

New Topic/Question
Reply




MultiQuote





|