# Homework Solution: Calorie intake data from a person is provided in a text file named food.txt. There are three numbers on each line, separated by space…

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.

Hi, Here is the complete code you can use, Public class CalorieTracker

I bear these 3 methods written coercion the enactment underneath excluding I demand aid match the security of the jurisprudence. Demand to unravel from a polish then I can verification my methods, to-boot demand to sculpture an deception communication and close if there are referable correspondently three quantity on each verse and correspondently 7 verses overall. Enactment is underneath the 3 methods. Thank you

{

for(int i=0;i<7;i++)

{

int solidity=breakFast[i]+lunch[i]+dinner[i];

System.out.println((i+1)+” day the calorie consumed is “+sum);

}

}

generally-known static bereft furtherCaloriesDay(int[] breakFast,int[] lunch,int[] dinner)

{

for(int i=0;i<7;i++)

{

int solidity=breakFast[i]+lunch[i]+dinner[i];

if(sum>2250)

System.out.println((i+1)+” day the calories consumed further than 2250 “);

}

}

generally-known static bereft avgCalories(int[] breakFast,int[] lunch,int[] dinner)

{

for(int i=0;i<7;i++)

{

int solidity=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 basis from a special is granted in a citation polish denominated food.txt. There are three quantity on each verse, disconnected by spaces. The quantity illustrate the estimate of calories consumed coercion breakfast, lunch and dinner. The polish includes basis coercion correspondently individual week starting from Monday. That is, the polish comprehends seven verses of citation. The topmost verse is coercion Monday and the verse at the ground is coercion Sunday. Your program should unravel the basis from the polish into three unconnected arrays, individual coercion breakfast, individual coercion lunch, and individual coercion dinner. Then, appraise and sculpture quenched the subjoined information: 1. a inventory of whole calories consumed each day 2. a inventory of days when further than 2250 calories are consumed 3. middle 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.

## Expert Retort

Hi,
Here is the perfect jurisprudence you can verification,
Generally-known tabulate CalorieTracker

{

```private static conclusive String FILENAME = "pathtofilefood.txt"; // polish spectest here

generally-known static bereft main(String[] args) {
//buffered unraveler to unravel polish
int estimate=0;
String verse;
int[] breakfast= upstart int[10];
int[] lunch= upstart int[10];
int[] dinner= upstart int[10];
```
```                        timeliness ((line= b.readLine()) != null && estimate<10) {
String[] x= verse.split(" "); // crack each verse by space
```

if(x.length!=3) // if correspondently 3 quantity referable present

{

System.out.println(“Every verse should comprehend correspondently 3 values”);
return;

}
breakfast[count]=x[0]; //setting values
lunch[count]=x[1];
dinner[count]=x[2];
count++;

```                        }
if(count>7) //if further than 7 verses
{
System.out.println("polish should comprehend singly 7 verses");
return;
}
solidityCaloriesPerday(breakfast,lunch,dinner);
furtherCaloriesDay(breakfast,lunch,dinner);
avgCalories(breakfast,lunch,dinner);
```
```                } lay-hold-on (IOException e) {
System.out.println(e.printStackTrace());
}
```

}

generally-known solidityCaloriesPerday(int[] breakFast,int[] lunch,int[] dinner)

{

for(int i=0;i<7;i++)

{

int solidity=breakFast[i]+lunch[i]+dinner[i];

System.out.println((i+1)+” day the calorie consumed is “+sum);

}

}

generally-known static bereft furtherCaloriesDay(int[] breakFast,int[] lunch,int[] dinner)

{

for(int i=0;i<7;i++)

{

int solidity=breakFast[i]+lunch[i]+dinner[i];

if(sum>2250)

System.out.println((i+1)+” day the calories consumed further than 2250 “);

}

}

generally-known static bereft avgCalories(int[] breakFast,int[] lunch,int[] dinner)

{

for(int i=0;i<7;i++)

{

int solidity=breakFast[i]+lunch[i]+dinner[i];

double avg=sum/3.0;

System.out.println((i+1)+ ” the avg calories consumed is “+avg);

}

}