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

  Write the java code for classes team and player

Write the Java code for classes Team and Player. Declare the classes in package com.myleague.reg. Provide an implementation of all methods according to the given method names. You can use the class Random fromjava.util to randomly pick a student

  Consider a class that could be used to play a game of

consider a class that could be used to play a game of hangman. the class has the following attributesthe secret wordthe

  Create a road class

Create a Road class. The class should have functions for setting the width of the road in feet and the length of the road in miles. It should also have functions for obtaining the width of the road the length of the road.

  Start a new project and package

Write your own name and that of your programming partner on the top of page. Start a new project and package called PA3 and set up your programs inside.

  Problem regarding the java bytecode analysis

One property of a Java program that is checked by the veri?er is that each object must be properly initialized before it is used. This property is fairly dif?cult to check. One relatively simple part of the analysis, however, is to guarantee that ..

  Write a program that prompts a user to enter a us dollar

Write a program that prompts a user to enter a US dollar amount. Output a table similar to the one in the example below. The second prompt should ask the user to enter a 1 to convert to euros, a 2 to convert to pounds and a 3 to convert to ruble..

  Implement a method with three arguments

Implement a method with three arguments: a graph, a starting vertex number, and an ending vertex number. The method determines whether there is a directed path from the starting vertex to the ending vertex.

  Write a program that ask the user to enter a usemame

Write a program usennuftevalidator.java that ask the user to enter a usemame and checks whether the usemame meets the following criteria

  Program to translates a number into the closest letter grade

Write a program that translates a number into the closest letter grade. For example, the number 2.8 (which might have been the average of several grades) would be converted to B-. Break ties in favor of the better grade

  What would be an incorrect way of writing this equation

Jim develops 5 Java applications a year. Joe develops 10 Java applications a year. Jim gets paid $5000.00 per application, but Joe gets paid $10000.00 per application.

  Write a java program that creates three threads

The reader-writer problem can be stated as given: A shared memory location can be concurrently read by any number of tasks, but when a task must write to the shared memory location, it must have exclusive access.

  Multiple choice java programming questions

Determine which of the following may be a violation of information hiding if inserted for the comment above?

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