Answered Essay: Objective: The goal of this assignment is to practice 2-dimensional ragged arrays. Background: Within a healthy, bala

Objective: The goal of this assignment is to practice 2-dimensional ragged arrays. Background: Within a healthy, balanced diet, a grownup needs 2,250 calories a day You will write a program to track calorie intake of a person. Assignment: Calorie intake data from a person is provided in a text file named input.txt. There are arbitrary number of double values on each line, separated by spaces. The numbers represent the number of calories consumed for meals and/or snacks on a day. 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 a 2- dimensional array. The number of rows of the 2-dimensional array must be equal to the number of valid lines in the file. The numbers in the i-th row of the 2-dimensional array must appear in the same sequence of numbers in the i-th row of the file. After reading the input file into the 2-dimensional array, report the following items. a list of total calories consumed each day . a list of days when more calories than required are consumed average calories consumed during the i-th meal/snack (average over all seven days) You must write a method with exactly one 2-dimensional array parameter to compute each of the listed items above and display the result. Example input file: 800 1000 100 450 100 845 20 1200 200 1800 250 400 0 1500 800 120 600 500 700 1400 1700 100 675 You should print an error message and terminate if there are not exactly 7 lines Deliverables: The name of your source file must be Fitness.java. It must be submitted via Blackboard. Your TAs will let you know about any other requirements. Java

Objective: The goal of this assignment is to practice 2-dimensional ragged arrays. Background: Within a healthy, balanced diet, a grownup needs 2,250 calories a day You will write a program to track calorie intake of a person. Assignment: Calorie intake data from a person is provided in a text file named input.txt. There are arbitrary number of double values on each line, separated by spaces. The numbers represent the number of calories consumed for meals and/or snacks on a day. 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 a 2- dimensional array. The number of rows of the 2-dimensional array must be equal to the number of valid lines in the file. The numbers in the i-th row of the 2-dimensional array must appear in the same sequence of numbers in the i-th row of the file. After reading the input file into the 2-dimensional array, report the following items. a list of total calories consumed each day. a list of days when more calories than required are consumed average calories consumed during the i-th meal/snack (average over all seven days) You must write a method with exactly one 2-dimensional array parameter to compute each of the listed items above and display the result. Example input file: 800 1000 100 450 100 845 20 1200 200 1800 250 400 0 1500 800 120 600 500 700 1400 1700 100 675 You should print an error message and terminate if there are not exactly 7 lines. Deliverables: The name of your source file must be Fitness.java. It must be submitted via Blackboard. Your TAs will let you know about any other requirements.

Expert Answer

 

package car;
import java.util.*;
import java.io.*;
public class fitness {
final int limit=7;
final static int requiredcolory=1500;
public static void main(String[] args) {
int arr[][]=new int[7][];
String line=””;
int counter=0;
int allcounter=0;
int sum=0;
try{
BufferedReader br=new BufferedReader(new FileReader(new File(“src/car/colory”)));
while((line=br.readLine())!=null){
String[] splits=line.split(” “);
arr[counter]=new int[splits.length];
System.out.print(“Day:”+(counter+1)+”=”);
for(int i=0;i<arr[counter].length;i++){
arr[counter][i]=Integer.parseInt(splits[i]);
System.out.print(arr[counter][i]+” “);
//System.out.print(arr[counter].length);

}
counter++;
System.out.println();
if(counter>7){
System.out.println(“input data exceding limit 7:”);
break;
}
}
}catch(Exception e){
System.out.println(“error in reading file:”+e);
}
for(int i=0;i<arr.length;i++){
for(int j=0;j<arr[i].length;j++){
sum+=arr[i][j];
if(arr[i][j]>requiredcolory)
System.out.println(“Day:”+(i+1)+” has colory greter than requirement”);
allcounter++;
}
}
System.out.println(“average colories is:”+(sum/allcounter));
}
}

output:
Day_1=800 1000 100
Day_2=450 100 845 20 1200 200
Day_3=1800 1250 400
Day_4=0 1500 800 200
Day_5=600 500
Day_6=700 1400 1700 100
Day_7=675
Day:3 has colory greter than requirement
Day:6 has colory greter than requirement
average colories is:710

input file:
colory.txt
800 1000 100
450 100 845 20 1200 200
1800 1250 400
0 1500 800 200
600 500
700 1400 1700 100
675

screenshots:

/* i had package called car..so i place both text file and fitness file in that package..and be sure about the path of text file you mentioned in your program
i used “src/car/colory” as per my directory..
*/

Buy Essay
Calculate your paper price
Pages (550 words)
Approximate price: -

Help Me Write My Essay - Reasons:

Best Online Essay Writing Service

We strive to give our customers the best online essay writing experience. We Make sure essays are submitted on time and all the instructions are followed.

Our Writers are Experienced and Professional

Our essay writing service is founded on professional writers who are on stand by to help you any time.

Free Revision Fo all Essays

Sometimes you may require our writers to add on a point to make your essay as customised as possible, we will give you unlimited times to do this. And we will do it for free.

Timely Essay(s)

We understand the frustrations that comes with late essays and our writers are extra careful to not violate this term. Our support team is always engauging our writers to help you have your essay ahead of time.

Customised Essays &100% Confidential

Our Online writing Service has zero torelance for plagiarised papers. We have plagiarism checking tool that generate plagiarism reports just to make sure you are satisfied.

24/7 Customer Support

Our agents are ready to help you around the clock. Please feel free to reach out and enquire about anything.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

HOW OUR ONLINE ESSAY WRITING SERVICE WORKS

Let us write that nagging essay.

STEP 1

Submit Your Essay/Homework Instructions

By clicking on the "PLACE ORDER" button, tell us your requires. Be precise for an accurate customised essay. You may also upload any reading materials where applicable.

STEP 2

Pick A & Writer

Our ordering form will provide you with a list of writers and their feedbacks. At step 2, its time select a writer. Our online agents are on stand by to help you just in case.

STEP 3

Editing (OUR PART)

At this stage, our editor will go through your essay and make sure your writer did meet all the instructions.

STEP 4

Receive your Paper

After Editing, your paper will be sent to you via email.