Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Assignment (Part 2: 25 points): The client comes back and would like you to make

ID: 3746472 • Letter: A

Question

Assignment (Part 2: 25 points): The client comes back and would like you to make the program more general, so that it can handle any number of meals in any of the days of a week. That is, you no longer know that there will be exactly three columns in the data; however, the number of lines is still seven. Consider that the first meal of the day is Meal 1", the second meal is Meal 2", so and so forth. You may assume that a person eats at least once a day. That is, each row will have at least one number. Example input file: Your program must read the input from a file named input2. txt 200 1000 450 845 1200 800 800 400 1500 1800 200 500 1000 700 1400 170 675 400 100 400 300 Use the concept of 2-dimensional Ragged Array to solve the second part of the assignment. In the second part, the client is only interested in the following nformation now. the average number of calories consumed each day the average number of calories consumed in every meal of the week. For the example input file above the list of averages for Meals 1 to 5 is: 532.1428571, 1024.166667,817.5, 466.6666667, and 300

Explanation / Answer

Note: I will update this with average calories consumed .Thank You.

AveargeCaloriesConsumed.java

import java.io.File;

import java.io.FileNotFoundException;

import java.util.Scanner;

public class AveargeCaloriesConsumed {

public static void main(String[] args) {

int arr[][]=new int[7][];

try {

Scanner sc=new Scanner(new File("jarray.txt"));

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

{

String str=sc.nextLine();

String arr1[]=str.split(" ");

arr[i]=new int[arr1.length];

for(int j=0;j<arr1.length;j++)

{

arr[i][j]=Integer.parseInt(arr1[j]);

}

}

} catch (FileNotFoundException e) {

e.printStackTrace();

}

System.out.println("Iterating Through the Jagged Array");

for (int i = 0;i < arr.length;i++)

{

for (int j = 0;j < arr[i].length;j++) {

System.out.print(arr[i][j]+ " ");

}

System.out.println("");

}

}

}

_________________