Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

*This is using Java, currently practicing on notepad ++ import java.io.*; import java.util.Scanner; public class Fitness { public static void main(String[] args)throws Exception { Calorie

image text in transcribed

*This is using Java, currently practicing on notepad ++

import java.io.*;

import java.util.Scanner;

public class Fitness {

public static void main(String[] args)throws Exception {

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 davs 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. xample 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Integration Services

Authors: Brian Knight, Devin Knight

1st Edition

1118850904, 9781118850909

More Books

Students also viewed these Databases questions