-
Language
JavaScript
-
Description
Need to write a program to convert Seconds in to Hours Minutes and Seconds. You should obtain number of seconds as user input (Integer Value). Convert the seconds obtain in to Hours, Minutes and Seconds and display that to the User.
Need to have the output of the code in this format:
Enter a number of seconds: 500
Here is the time in hours, minutes, and seconds:
Hours: 0.0
Minutes: 8.0
Seconds: 20.0
where "500" is the input and the other numbers are the output.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "https://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Converts a number of seconds in to hours and minutes</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script>
<html>
<head>
<title>Converts a number of seconds in to hours and minutes</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script>
function algorithm()
{
let hours, minutes, number_of_seconds, seconds;
number_of_seconds = parseInt (document.form1.number_of_seconds.value);
seconds=number_of_seconds%60;
minutes=(number_of_seconds-seconds)/60;
hours=(minutes-minutes%60)/60;
minutes=minutes%60;
document.form1.hours.value = hours;
document.form1.minutes.value = minutes;
document.form1.seconds.value = seconds;
}
{
let hours, minutes, number_of_seconds, seconds;
number_of_seconds = parseInt (document.form1.number_of_seconds.value);
seconds=number_of_seconds%60;
minutes=(number_of_seconds-seconds)/60;
hours=(minutes-minutes%60)/60;
minutes=minutes%60;
document.form1.hours.value = hours;
document.form1.minutes.value = minutes;
document.form1.seconds.value = seconds;
}
</script>
</head>
<body>
<form name="form1">
<table style="text-align: left; margin-left: auto; margin-right: auto;">
<tbody>
<tr>
<td>
<label for="number_of_seconds">Enter the value of number of seconds:</label>
</td>
<td>
<input name="number_of_seconds" required="required" step="1" type="number" />
</td>
</tr>
<tr align="center">
<td colspan="2" rowspan="1">
<input value="Process" type="button" onclick="algorithm();" />
<input type="reset" />
</td>
</tr>
<tr>
<td>
<label for="hours">Value of hours:</label>
</td>
<td>
<input name="hours" step="1" type="number" />
</td>
</tr>
<tr>
<td>
<label for="minutes">Value of minutes:</label>
</td>
<td>
<input name="minutes" step="1" type="number" />
</td>
</tr>
<tr>
<td>
<label for="seconds">Value of seconds:</label>
</td>
<td>
<input name="seconds" step="1" type="number" />
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>
</head>
<body>
<form name="form1">
<table style="text-align: left; margin-left: auto; margin-right: auto;">
<tbody>
<tr>
<td>
<label for="number_of_seconds">Enter the value of number of seconds:</label>
</td>
<td>
<input name="number_of_seconds" required="required" step="1" type="number" />
</td>
</tr>
<tr align="center">
<td colspan="2" rowspan="1">
<input value="Process" type="button" onclick="algorithm();" />
<input type="reset" />
</td>
</tr>
<tr>
<td>
<label for="hours">Value of hours:</label>
</td>
<td>
<input name="hours" step="1" type="number" />
</td>
</tr>
<tr>
<td>
<label for="minutes">Value of minutes:</label>
</td>
<td>
<input name="minutes" step="1" type="number" />
</td>
</tr>
<tr>
<td>
<label for="seconds">Value of seconds:</label>
</td>
<td>
<input name="seconds" step="1" type="number" />
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>