Computer Science, asked by sandy2177177, 11 months ago

Edhesive 2.3 Code Practice: question 3
Write a program that accepts a time as an hour and minute. Add 15 minutes to the time, and output the result.

Example 1:

Enter the hour: 8
Enter the minute: 15
It displays:

Hours: 8
Minutes: 30
Example 2:

Enter the hour: 9
Enter the minute: 46
It displays:

Hours: 10
Minutes: 1
HINT: First, try to solve the problem where hours go from {0,1,2,...8,9,10,11} instead of {1,2,3...,9,10,11,12}. This should be similar to your answer for Q2. Then, find a way to convert your final answer for hours from a {0,1,2,...8,9,10,11} time system to a {1,2,3...,9,10,11,12} time system.

Answers

Answered by Anonymous
1

Answer:

Here we are checking if the limit of the  minute, if it is crossing 60  then divide the minute by 60 and add the result with the hour and remainder with minute otherwise then add the hours and minutes

timeinhour = int(input("Input the hour: "))

timeinminute = int(input("Input the minute: "))

extra = 15

totalminute = timeinminute +extra

if (totalminute <=60)

{

totaltime = timeinhour +totalminute

}

else

{  int m = totalminute % 60

timeinhour = timeinhour +(totalminute /60)

totaltime = timeinhour +m

}

print("totaltime-> %d" % (totaltime))

Similar questions