Write a java program that accepts the minutes as input [pass input as a
parameter through the method]and convert them into the corresponding
number of hours and minutes.Example: Input: Number of Minutes : 507
Output: Number of hours : 8
Number of remaining Minutes :27 (java program)
Answers
Answer:
In this java program, we are reading number of seconds from the user and converting the seconds into hours, minutes and seconds and printing in HH:MM:SS format.
Explanation:
Hope it is helpful to you
PLEASE mark me BRAINLIST
Answer:
Output:
22:22
Explanation:
You are given a time T in 24-hour format (hh:mm) and a positive integer K, you have to tell the time after K minutes in 24-hour time.
Examples:
Input: T = 12:43, K = 21
Output: 13:04
Input: T = 20:39, K = 534
Output: 05:33
Recommended: Please try your approach on {IDE} first, before moving on to the solution.
Approach:
Convert the given time in minutes
Add K to it let it be equal to M.
Convert the M minutes in 24 hours format accordingly.
Below is the implementation of the above approach:
#include <bits/stdc++.h>
using namespace std;
// function to obtain the new time
void findTime(string T, int K)
{
// convert the given time in minutes
int minutes = ((T[0] - '0')
* 10
+ T[1] - '0')
* 60
+ * 10+ T[4] - '0'); // Add K to current minutes minutes += K; // Obtain the new hour and new minutes from minutes int hour = (minutes / 60) % 24; int min = minutes % 60; // Print the hour in appropriate format if (hour < 10) { cout << 0 << hour << ":"; } else {cout << hour << ":"; } // Print the minute in appropriate format if (min < 10) {cout << 0 << min; } else { cout << min; } } // Driver code int main() { string T = "21:39"; int K = 43; findTime(T, K); }