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

  A remote web-based file storage application

Develop a web-based application. The server-side part of the application must be developed using Java Servlets (possibly including JSP). The development of the client (browser) side will typically be a combination of HTML and Javascript.

  Create your own online store web site selling products of

create your own online store web site selling products of your choice.create pages that allow you to search and buy

  Translates a number into the closest letter grade

Write a program that translates a number into the closest letter grade. For case, the number 2.8 which might have been the average of several grades would be converted to B-

  Videorental store operatorrecord clients

Project is to design a program to help a videorental store operatorrecord clients' transactions - Design a primitive database indicating

  Write a script that inputs several lines of text

Write a script that inputs several lines of text and a search character and uses String method indexOf to determine the number of occurrences of the character in the text.

  What is the purpose of using javascript on a website

What is the purpose of using JavaScript on a website. What is a specific example of a JavaScript application that will be beneficial on the site you are creating. Use an example other than from validation.

  Write a java application that reads a file containing text

Write a Java application that reads a file containing text. Your program should read each line and display it on the console screen preceded by line numbers. If the input file is:

  Kinds of functionality in the graphical sense

You have to be familiar with the "Fun" part of Java utilizing the GUI. - Why do you think Java and Java's GUI are so popular?

  Unique index integer fields

Unique index integer fields Use at least 5 other fields of various, including at least one of each of String, int and double types. assume that the String's have no spaces within them

  Discuss the fundamentals of object oriented programming

Include an accompanying illustration for each of the fundamentals(example, code sample, etc.)Note: Try to use Java and not C++ for examples.

  Objectivesbullto exercise the analysis design and

objectivesbullto exercise the analysis design and implementation activities of software development.bullto learn

  Design a program in pseudocode

Design a program in pseudocode that solves this problem. You are required to generate only the pseudocode - No charting or analysis section is required, but you may have to incorporate the bubble sort algorithm to determine the minimum and maximum..

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