Question: In Java Calorie intake data from a person is provided in a text file named food.txt. There are three numbers on each line, separated by
In Java
Calorie intake data from a person is provided in a text file named food.txt. There are three numbers on each line, separated by spaces. The numbers represent the number of calories consumed for breakfast, lunch and dinner, respectively. The file includes data for exactly one week starting from Monday. That is, the file contains seven lines of text. The topmost line is for Monday and the line at the bottom is for Sunday. Your program should read the data from the file into three separate arrays, one for breakfast, one for lunch, and one for dinner. Then, compute and print out the following information: 1. a list of total calories consumed each day 2. a list of days when more calories than required are consumed 3. average calories consumed during each of the three meals You must write a method with exactly three array parameters to compute each of the listed items above and display the result You should print an error message and terminate if there are not exactly three numbers on each line, and exactly 7 lines overall.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
