Question

In: Computer Science

PSUEDOCODE: Using whatever looping mechanism makes sense to you, create an algorithm that will display timing...

PSUEDOCODE: Using whatever looping mechanism makes sense to you, create an algorithm that will display timing for a stopwatch.

Keep the following in mind:

  • We can assume that you're processing on the world's oldest, slowest computer and that each iteration of a loop takes exactly one/100th of a second
  • The user needs to see fractions of a second all the way to 24 hours - any more and we should really call for medical help...
  • Provide a way for the user to be able to stop the procedure at any time

Solutions

Expert Solution

Here the question isn't giving a exact description of what is needed but I'll assume we need to print the time in a stop watch and the user to stop it at anytime.

Now there are two thing we have to do,

Check if user has tried to close us and if the time is 24hrs so we can the hospital where as in any other situation we just need to increase value by 1/100 of a second.

import sys

HR=0

Min=0

milli=0

second = 0

while(true):
    try: if(HR=23 and min==59 and Second ==59 and milli= 99):
               Print( " calling the hospital")
         elif(min==59 and second = 59 and Milli ==99):

HR +=1

min=0

second = 0

milli = 0

elif(second=59 and milli=99):

min+=1

second = 0

milli=0

elseif(Milli==99):

second+=1

milli=0

else:

milli+=1

print(Hr,":",minute,":",second,":",Milli)

   except KeyboardInterrupt:
          sys.exit()

Go over the code this will work if every loop takes 1/100 of a second of a millisecond and as soon as something is pressed it or will call hospital on completion of 24 hrs

Hope it helps


Related Solutions

1. Write pseudocode for the algorithm using iteration (looping). Envision an algorithm that when given any...
1. Write pseudocode for the algorithm using iteration (looping). Envision an algorithm that when given any positive integer n, it will print out the sum of the squares from 1 to n. For example given 3 the algorithm will print 14 (because 1 + 4 + 9 =14) You can use multiplication denoted as * in your solution and you do not have to define it (For example. 3*3=9) For example if n is 6 it will print: The sum...
Question 1: Using Python 3 Create an algorithm The goal is to create an algorithm that...
Question 1: Using Python 3 Create an algorithm The goal is to create an algorithm that can sort a singly-linked-list with Merge-sort. The program should read integers from file (hw-extra.txt) and create an unsorted singly-linked list. Then, the list should be sorted using merge sort algorithm. The merge-sort function should take the head of a linked list, and the size of the linked list as parameters. hw-extra.txt provided: 37 32 96 2 25 71 432 132 76 243 6 32...
Bonding 8. a. Using whatever method you like, determine the shape of CF4 b. Using whatever...
Bonding 8. a. Using whatever method you like, determine the shape of CF4 b. Using whatever method you like, determine the shape of HBr c. Using whatever method you like, determine the shape of PF3 d. Using whatever method you like, determine the shape of CO2
solution using stack Reversing a word or a sentence: Write an algorithm that will display a...
solution using stack Reversing a word or a sentence: Write an algorithm that will display a given word in a reverse order. - e.g. "Data Structures" will be "serutcurtS ataD".
Create a program called DualPivotQuickSort.java that implements the QuickSort algorithm using Yaroslavskiy’s algorithm. The program should...
Create a program called DualPivotQuickSort.java that implements the QuickSort algorithm using Yaroslavskiy’s algorithm. The program should be able to do the following: accepts one command line parameter. The parameter specifies the path to a text file containing the integers to be sorted. The structure of the file is as follows: There will be multiple lines in the file (number of lines unknown). Each line will contain multiple integers, separated by a single whitespace. reads the integers from the text file...
Create some ideas for new offerings from Broad Reach Sailing. Decide if it makes sense to...
Create some ideas for new offerings from Broad Reach Sailing. Decide if it makes sense to take on new partners and what the pros and cons might be in making this decision. Do you have what it takes to be a successful entrepreneur? Do you think successful entrepreneurs are born with these traits or if these traits be learned?
Write psuedocode and Java code using JOptionPane Scenario: ABC Resort and Hotel has approached you to...
Write psuedocode and Java code using JOptionPane Scenario: ABC Resort and Hotel has approached you to write a program to keep track of the number of rooms needed for an event. Customers can request any one of the following types of rooms to be reserved. Because the hotel has limited rooms available for a given event, it can only reserve up to 39 rooms. However, the hotel does not know how many rooms, in total, will be reserved because the...
Are there any scenarios that you can think of that makes more sense to get the...
Are there any scenarios that you can think of that makes more sense to get the money in the future versus today? What about lottery winnings? Would you prefer the winnings now or payouts over a period of time?
Create Kernel of a Strongly Connected Components using Kosaraju's Algorithm in Java. I have to create...
Create Kernel of a Strongly Connected Components using Kosaraju's Algorithm in Java. I have to create a Kernel DAG using the Strongly Connected Components found using Kosaraju's Algorithm. The input to the code is in the format. 5 \n 5 \n 1 0 \n 0 2 \n 2 1 \n 0 3 \n 3 4 The code will find the SCCs and print them to the screen, however, I need to find a way to construct a kernel based on...
Using Eclipse IDE Create a Java Program/Class named MonthNames that will display the Month names using...
Using Eclipse IDE Create a Java Program/Class named MonthNames that will display the Month names using an array. 1. Create an array of string named MONTHS and assign it the values "January" through "December". All 12 months need to be in the array with the first element being "January", then "February", etc. 2. Using a loop, prompt me to enter an int variable of 1-12 to display the Month of the Year. Once you have the value, the program needs...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT