Question
USING JAVA AND USE SCANNER TO READ FROM THE FILE. Calorie intake data from a person is provided in a text file named food.txt. There
USING JAVA AND USE SCANNER TO READ FROM THE FILE. Calorie intake data from a person is provided in a text file named food.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. NEED A METHOD FOR EACH OF THESE THREE ITEMS 1. LIST OF TOTAL CALORIES CONSUMED EACH DAY 2. LIST OF DAYS WHEN MORE THAN 2250 CALORIES WERE CONSUMED 3. AVERAGE CALORIES CONSUMED DURING THE I-TH MEAL/SNACK(AVERAGE OVER ALL SEVEN DAYS) You should print an error message and terminate if there are not exactly 7 lines.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started