Compute a java programming writing a number converter

Assignment Help JAVA Programming
Reference no: EM131158942

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.

Reference no: EM131158942

Questions Cloud

How your life will change from this morning on : Using a comparative perspective, what differences and similarities do you see between Islamic Fundamentalism, Christian Fundamentalism in the United States, and the revitalization movements discussed in the text?
Narrative presented in amy gilman srebnick : (Drawing upon the narrative presented in Amy Gilman Srebnick's The Mysterious Death of Mary Rogers, identify two or three themes that support your side of the argument, and illustrate your analysis with examples from the book.)
British first came to east africa : Problem: As the British first came to east Africa, was Uganda a colony or a protectorate?
Aims of revolutionary predecessors : 1. Evaluate how Napoleon both continued and broke from the aims of his revolutionary predecessors.
Compute a java programming writing a number converter : Compute a 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.
Experience different rates of development : Various communities in Kenya experience different rates of development. It has been argued that education inequality in the country is the driving force behind this. Discuss various factors contributing to education inequalities in Kenya and appro..
Defend cost classification to the us government : Determine reasonable, allowable, allocable, variable, fixed & semi-variable costs for your company after the initial startup phase is complete.
Contrast the american revolutionary war : Compare and contrast the American Revolutionary war and the French Revolution (Your essay should have an introductory paragraph with a thesis statement as the last sentence in the paragraph, several well-organized supporting paragraphs
Issues relating to nevada history : Write a 260- to 350-word narrative discussing the following key issues relating to Nevada's history:

Reviews

Write a Review

JAVA Programming Questions & Answers

  Java application to carry out additions and subtractions

Design a Java application to carry out additions and subtractions for numbers of any length. A number is represented as an object which includes a sign and two strings for the whole and decimal parts of the number.

  Java program using the net beans ide

For this Assignment, you will update an existing Java program using the NetBeans IDE. You will use the NetBeans Integrated Development Environment to make changes to an existing NetBeans Java Project.

  Objectivesto gain experience with arrays to gain

objectivesto gain experience with arrays. to gain experience with generic algorithms.documentationexplain

  Give at least one constructor without any parameter

We learned as popular Set implementation. Write own TreeSet class that implements following interface: You are to give at least one constructor without any parameter.

  Java program using jgrasp and the software development kit

Design a GUI program to find the weighted average of four test scores. The four test scores and their respective weights are given in the following format:

  Develop your first android app which simply displays text

Develop your first Android App, which simply displays the following text: "Hello Android, my name is ." Test your deveopment environment using the sample project (legacy-Snake).

  Prison sentence for armed burglary

Compose a letter to an employer explaining why you should be hired even though you have just completed a 5 year prison sentence for armed burglary. Specify the type of company you are applying for.

  Give the syntax of do while statement

Please complete the following short answer questions with code snippets as well as paragraphical responses. This assignment should not be an exercise in copy and paste, but an assessment of your comprehension and evaluation of the course materials..

  Demonstrate your knowledge in a pragmatic way

Summarize everything that we have addressed in the XML Applications course, and provide a mechanism to demonstrate your knowledge in a pragmatic way.

  Construct java applications

Construct Java applications that demonstrate string manipulation, file input and output, and error handling. Create a Graphical User Interface application

  Creating the gui for the game interface

A GUI-based application that allows a user to play a simple trivia game

  Update your website to include a simple web form

Update your website to include a simple web form as discussed in your design document. Use JavaScript to validate the form contents and display the results of that validation to the user in a popup window

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd