Question: Code in Java programming please just the code will be fine the csv file is a bunch of 0's You have been tasked to write




You have been tasked to write a program to interpret the output of a bed pressure sensor. This sensor logs the activity of a sleeper once a second for a period of 24 hours and then outputs the data to a file. The possible values in the data file are as follows: 0-Deep sleep (uninterrupted pressure sensed on the pad) 1 - Restless sleep interrupted pressure sensed on the pad) 2 - Interrupted sleep (no pressure sensed on the pad, individual is not on the bed) The first data point is captured at 12:00 midnight and the last data point is captured at 11:59 pm. You may use the following example to read the data file, sleep_data.csv. import java.io.File; // Import the File class import java.io.FileNotFoundException; // Inport this class to handle errors import java.util.Scanner; // Import the Scanner class to read text files public class ReadFile { public static void main(String[] args) { try { File myobj = new File("sleep_data.csv"); Scanner myReader = new Scanner (myObj); while (myReader.hasNextLine()) { String data = myReader.nextLine(); System.out.println(data); } my Reader.close(); } catch (FileNotFoundException e) { System.out.println("An error occurred."); e.printStackTrace(); The above code will read the file and simply display the output on the screen. You must place the sleep_data.csv in the top level of your project folder (where the bin and src folders are). Required Submission: Calculate the following statistics and display in a tabular format as shown below: Sleep report for 24 hour period Wake Time: 4.699722222222222 hours after midnight Sleep Time: 21.4 hours after midnight Duration Deep Sleep: 5.994166666666667 hours Duration of Restless Sleep 0.6680555555555555 hours Duration of Interrupted Sleep 0.6375 hours Sleep Quality: 7.298402777777778 The equation to calculate sleep quality is as follows: 10* (Deep Sleep)/(8*3600) Restless Sleep)*0.1/3600 - Interrupted Sleep) * 0.2/3600 Show a bar graph of how many seconds of sleep was recorded. The total number of asterisks in a bar graph represents 1% of the total number of seconds of sleep for that hour. Do not show any bars for periods where no sleep was detected. Sleep data aggregated by 1 hour periods: ********** 1: 2: 3: 4: 21: 22: 23: Extra Credit: Modify the bar graph so it displays seconds of sleep (as asterisks), restlessness (as plus signs), and interrupts (as minus signs): +20 points Sleep data aggregated by 1 hour periods: **************** (45.23 min) +++++++++ (13.43 min) 8: 1- (1.35 min) ******* (49.30 min) 1: +++++++ (10.70 nin) ***** (55.22 min) 2: |-- (4.78 min) ******** (60.00 min) 3: ******** (11.97 min) 4: ********************** (35.90 min) 1 + (0.12 min) 21: 1********** 1++++++ (9.60 min) ********* (58.48 min) 22: ***** (51.63 min) 23: | ++++ (6.23 min) 1- (2.12 min) Modify the sleep statistics so that time is reported in hours and minutes (or just minutes as appropriate) and sleep quality is displayed to a single digit of precision: +5 points Sleep report for 24 hour period Wake Time: Sleep Time: Duration Deep Sleep: Duration of Restless Sleep: Duration of Interrupted Sleep: 4:41 (military time) 21:24 (military time) 5 hours 59 minutes 40 minutes 8 minutes You must include a video (no more than 5 minutes) that describes your program in detail and the thought process behind the decisions that you made. The video should show your code and should provide a way to hear your voice and see which parts of the code you are referencing as your describe it. Treat this as an oral defense of your work You have been tasked to write a program to interpret the output of a bed pressure sensor. This sensor logs the activity of a sleeper once a second for a period of 24 hours and then outputs the data to a file. The possible values in the data file are as follows: 0-Deep sleep (uninterrupted pressure sensed on the pad) 1 - Restless sleep interrupted pressure sensed on the pad) 2 - Interrupted sleep (no pressure sensed on the pad, individual is not on the bed) The first data point is captured at 12:00 midnight and the last data point is captured at 11:59 pm. You may use the following example to read the data file, sleep_data.csv. import java.io.File; // Import the File class import java.io.FileNotFoundException; // Inport this class to handle errors import java.util.Scanner; // Import the Scanner class to read text files public class ReadFile { public static void main(String[] args) { try { File myobj = new File("sleep_data.csv"); Scanner myReader = new Scanner (myObj); while (myReader.hasNextLine()) { String data = myReader.nextLine(); System.out.println(data); } my Reader.close(); } catch (FileNotFoundException e) { System.out.println("An error occurred."); e.printStackTrace(); The above code will read the file and simply display the output on the screen. You must place the sleep_data.csv in the top level of your project folder (where the bin and src folders are). Required Submission: Calculate the following statistics and display in a tabular format as shown below: Sleep report for 24 hour period Wake Time: 4.699722222222222 hours after midnight Sleep Time: 21.4 hours after midnight Duration Deep Sleep: 5.994166666666667 hours Duration of Restless Sleep 0.6680555555555555 hours Duration of Interrupted Sleep 0.6375 hours Sleep Quality: 7.298402777777778 The equation to calculate sleep quality is as follows: 10* (Deep Sleep)/(8*3600) Restless Sleep)*0.1/3600 - Interrupted Sleep) * 0.2/3600 Show a bar graph of how many seconds of sleep was recorded. The total number of asterisks in a bar graph represents 1% of the total number of seconds of sleep for that hour. Do not show any bars for periods where no sleep was detected. Sleep data aggregated by 1 hour periods: ********** 1: 2: 3: 4: 21: 22: 23: Extra Credit: Modify the bar graph so it displays seconds of sleep (as asterisks), restlessness (as plus signs), and interrupts (as minus signs): +20 points Sleep data aggregated by 1 hour periods: **************** (45.23 min) +++++++++ (13.43 min) 8: 1- (1.35 min) ******* (49.30 min) 1: +++++++ (10.70 nin) ***** (55.22 min) 2: |-- (4.78 min) ******** (60.00 min) 3: ******** (11.97 min) 4: ********************** (35.90 min) 1 + (0.12 min) 21: 1********** 1++++++ (9.60 min) ********* (58.48 min) 22: ***** (51.63 min) 23: | ++++ (6.23 min) 1- (2.12 min) Modify the sleep statistics so that time is reported in hours and minutes (or just minutes as appropriate) and sleep quality is displayed to a single digit of precision: +5 points Sleep report for 24 hour period Wake Time: Sleep Time: Duration Deep Sleep: Duration of Restless Sleep: Duration of Interrupted Sleep: 4:41 (military time) 21:24 (military time) 5 hours 59 minutes 40 minutes 8 minutes You must include a video (no more than 5 minutes) that describes your program in detail and the thought process behind the decisions that you made. The video should show your code and should provide a way to hear your voice and see which parts of the code you are referencing as your describe it. Treat this as an oral defense of your work
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
