Write a program that asks for a time under the form of three information (hours, minutes, seconds). The program calculates and shows the time one second after. Incorrect inputs must be taken into account.
Tue Oct 05 2021 19:53:33 GMT+0000 (Coordinated Universal Time)
Saved by
@rahsinc
#javascript
let hour = Number(prompt("Enter the hour: "))
let minutes = Number(prompt("Enter the minutes: "))
let seconds = Number(prompt("Enter the seconds: "))
if (
hour >= 0 &&
hour <= 23 &&
minutes >= 0 &&
minutes <= 59 &&
seconds >=0 &&
seconds <= 59
){
seconds++
if (seconds === 60){
seconds = 0;
minutes++
if (minutes === 60){
minutes = 0;
hour++
if (hour === 24){
hour = 0;
}
}
}
console.log (`In a second the time will be ${hour}: ${minutes} : ${seconds}`);
}
else {
console.log("Enter correct information");
}
content_copyCOPY
Comments