Compute a java programming - writing a number converter


Computer Science - Java Programming - Writing a number converter

Surgeons have a very tough schedule throughout the day to deal with patients, perform surgeries, visit wards, and attend meetings among others. Assume a surgeon wants to take a nap during the day time, but, due to his schedule, he may not get many chances. He wants to take one nap with the longest break time. Write a program to help this surgeon find a suitable time for a nap. He also wants to know total free time that he has on that specific day.

To complete this Assignment:

Input

You need to take input of 3 parameters: time1, time2 and appointment description for all the appointments of day. The time1 represents the starting time of an appointment and the ending time is represented by time2. All times are specified in the form of hh:mm. The ending time of an appointment will always be after the starting time. The value of each attribute is separated by a single space. The appointment description is specified in the single quotes.The value in both of the times must be greater than or equal to 9:00 and less than or equal to 17:00. Therefore, you need to take the value into consideration i.e., nap cannot start before 9:00 and cannot last after 17:00.

Output

For each appointment, you need to do following. Assume start time of nap and maximum nap time are 00:00.1. Check if the difference between ending and starting time is greater than maximum nap time, then update the values of start time of nap with the value of starting time of current appointment and maximum nap time with the difference of time calculate for current appointment.2. Add this difference of time to the total free time of the day.

Once all the appointments are processed, you need to print the following:1. Schedule of the day: You can take a longest nap at hh:mm which will last for [H hours and] M minutes.2. The total free time available in the day is hh:mm where hh:mm is the time when the nap can start.

To display the length of the nap, follow these rules:If the total time X is less than 60 minutes, just print &"X minutes." If the total duration X is at least 60 minutes, print "Hhours and M minutes," where H = X ÷ 60 (integer division, of course) and M = X mod 60.

You don't have to worry about correct pluralization; i.e., you must print "1 minutes" or "1 hours" if that is the case.The duration of the nap is calculated by the difference between the ending time and the beginning time. That is, if anappointment ends at 14:00 and the next one starts at 14:47, then you have 14:47 - 14:00 = 47 minutes of possiblenapping.

If there is more than one longest nap with the same duration, print the earliest one. You can assume the physician won'tbe busy all day, so there is always time for at least one possible nap.

You can make the input simpler by asking user to specify one long string which contains the details of all theappointments of a single day using three parameters repeated in the format as “time1 time2 ‘appointmentdescription' time1 time2 ‘appointment description' ..." and then applying string processing to separate details. You canalso use an alternate approach by taking input of three parameters separately. The examples of both methods are shownbelow:

Sample Inputs and Outputs: Example #1: input is in the form of one long string:Enter details of all the appointments: 9:00 9:45 ‘Ward inspection' 10:00 11:30 ‘Patients' 12:00 13:00 ‘Lunch' 13:00 15:00‘Meeting' 16:30 17:00 ‘Reading'

Output: You can take longest nap at 15:00 and it will last for 1 hours and 30 minutes.Total free time during whole day is 2 hours and 15 minutes. Example #2: input is in the form of one long string:Enter details of all the appointments: 12:00 13:00 ‘Lunch invitation'Output:You can take longest nap at 13:00 and it will last for 4 hours and 0 minutes.Total free time during whole day is 7 hours and 0 minutes.

Example #3: Each parameter is taken as a separate input. You need to take confirmation from user if they want toadd an appointment for the day. If they confirms then ask details of an appointment, else, you will break thesequence of taking input and process all the appointments specified by the user.

Do you want to add an appointment? Yes Enter starting time: 9:00Enter ending time: 12:00Enter appointment description: ‘Patients'Do you want to add an appointment? YesEnter starting time: 12:00Enter ending time: 13:00Enter appointment description: ‘Lunch.'Do you want to add an appointment? YesEnter starting time: 13:00Enter ending time: 16:00Enter appointment description: ‘Operation theatre'Do you want to add an appointment? YesEnter starting time: 16:30Enter ending time: 17:00Enter appointment description: ‘Discussion'Do you want to add an appointment? No

Output: You can take longest nap at 16:00 and it will last for 30 minutes.Total free time during whole day is 30 minutes.

Note: You may need to look at substring() and indexOf() of String class to perform string processing in this programmingquestion. If you are facing difficulty to take input and process in the form of "hh:mm" then you take separate inputs forboth hours and minutes.

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Compute a java programming - writing a number converter
Reference No:- TGS01542237

Expected delivery within 24 Hours