Question: Please use Java Thanks You have been tasked to write a program to interpret the output of a bed pressure sensor. This sensor logs the

 Please use Java Thanks 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

Please use Java

Thanks

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; // Import 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 (my Reader.hasNextLine()) { String data = myReader.nextLine(); System.out.println(data); } myReader.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 sre folders are). "Wake Time" can be calculated by determining when "Interrupted sleep" has occurred for at least 30 minutes (getting up and going to the bathroom wouldn't count if it took less than 30 minute) "Sleep Time" is the first time "Restless sleep" or "Deep sleep" is encountered after the person has be determined to be out of bed (awake). 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.13722222222222222 hours Sleep Quality: 7.4 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: 0: 1* 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) (1.35 min) **** (49.30 min) |+++++ (10.70 min) 0: 1: ******** (55.22 min) 2: ********** (4.78 min) ****** (60.00 min) 3: | ******** (11.97 min) 4: 4: ******** (35.90 min) 21: 1 + (0.12 min) 1******* ++ (9.60 min) ***** (50.40 min) 22: 23: ***** ****** (51.63 min) 1 ++++ (6.23 min) |-- (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 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; // Import 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 (my Reader.hasNextLine()) { String data = myReader.nextLine(); System.out.println(data); } myReader.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 sre folders are). "Wake Time" can be calculated by determining when "Interrupted sleep" has occurred for at least 30 minutes (getting up and going to the bathroom wouldn't count if it took less than 30 minute) "Sleep Time" is the first time "Restless sleep" or "Deep sleep" is encountered after the person has be determined to be out of bed (awake). 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.13722222222222222 hours Sleep Quality: 7.4 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: 0: 1* 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) (1.35 min) **** (49.30 min) |+++++ (10.70 min) 0: 1: ******** (55.22 min) 2: ********** (4.78 min) ****** (60.00 min) 3: | ******** (11.97 min) 4: 4: ******** (35.90 min) 21: 1 + (0.12 min) 1******* ++ (9.60 min) ***** (50.40 min) 22: 23: ***** ****** (51.63 min) 1 ++++ (6.23 min) |-- (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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!