0

Guys i need help to write a program to convert days to seconds. The given code takes the amount of days as input.

I am trying a lot but not getting solution because i am new to coding.

22nd Mar 2021, 11:45 AM
Chetan Gujar
Chetan Gujar - avatar
7 Respuestas
0
how many hours in a day? how many minutes in an hour? how many seconds in a minutes? just multiply number of days by hours per day by minutes per hour and by seconds in a minute...
22nd Mar 2021, 11:48 AM
visph
visph - avatar
0
Thanks for help but i did all this, Can not make it in code. If input is = 2 Then ans should be= 2x24x60x60 I know this. Unable complete with code.
22nd Mar 2021, 11:51 AM
Chetan Gujar
Chetan Gujar - avatar
0
share your code to get more accurate answer ^^
22nd Mar 2021, 11:52 AM
visph
visph - avatar
0
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int days = scanner.nextInt(); //your code goes here } }
22nd Mar 2021, 12:21 PM
Chetan Gujar
Chetan Gujar - avatar
0
this is not your code attempt, this is the code template provided to you...
22nd Mar 2021, 12:22 PM
visph
visph - avatar
0
Yes you are right. In between i use Int a= 2 Int b= 24 Int c= 60 Int d= 60 And then i multiplied all these var. To get answer but code has error.
22nd Mar 2021, 12:37 PM
Chetan Gujar
Chetan Gujar - avatar
0
in the code template you have the 'days' variable initialized with user input... that's the one you should use to compute the number of seconds: days*24*60*60 the result of this expression should be outputed...
22nd Mar 2021, 12:39 PM
visph
visph - avatar