I have these 3 methods written for the assignment below but I need help writing the rest of the code. Need to read from a file then I can use my methods, also need to print an error message and terminate if there are not exactly three numbers on each line and exactly 7 lines overall. Assignment is below the 3 methods. Thank you
{
for(int i=0;i<7;i++)
{
int sum=breakFast[i]+lunch[i]+dinner[i];
System.out.println((i+1)+” day the calorie consumed is “+sum);
}
}
public static void moreCaloriesDay(int[] breakFast,int[] lunch,int[] dinner)
{
for(int i=0;i<7;i++)
{
int sum=breakFast[i]+lunch[i]+dinner[i];
if(sum>2250)
System.out.println((i+1)+” day the calories consumed more than 2250 “);
}
}
public static void avgCalories(int[] breakFast,int[] lunch,int[] dinner)
{
for(int i=0;i<7;i++)
{
int sum=breakFast[i]+lunch[i]+dinner[i];
double avg=sum/3.0;
System.out.println((i+1)+ ” the avg calories consumed is “+avg);
}
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. 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 than 2250 calories 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 THREE LISTED ITEMS ABOVE AND DISPLAY THE RESULT.YOU SHOULD PRINT AN ERROR MESSAGE AND TERMINATE IF THERE ARE NOT EXACLTY THREE NUMBERS ON EACH LINE AND EXACTLY 7 LINES OVERALL.