0

How to fix this

Convert days to second Code: Import java.util.Scanner; public class program{ Public static void main(String []args){ System.out.println("Enter the days"); Scanner sc= new Scanner (System.in); int days = sc.nextInt(); int dayToHour= days*24; /* 1day=24hour */ int dayToMintue = dayToHour*60; /* 1hour=60min */ int dayToSecond = dayToMintue*60; /* 1min=60 sec */ System.out.println ("converting days to second: " + dayToSecond ); } }

8th Nov 2021, 9:01 AM
Meghna Som
9 ответов
+ 2
And the problem in in your print statement u dont need to print any string u just need to print value
8th Nov 2021, 3:44 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 1
What that bug? Is it code coach problem? Share link code that helps to identify what is the mistake..Meghna Som Add Expected output with problem description..
8th Nov 2021, 10:22 AM
Jayakrishna 🇮🇳
0
Do following changes. Import to import Public to public
8th Nov 2021, 9:16 AM
Sushil 🛡️
Sushil 🛡️ - avatar
0
"I also tried this .... Like: Int second = days*24*60*60; But it couldn't run .. It's show me a bugs ..." Yes, because it's wrong. Write 'int' instead of 'Int', with lower case 'i'. Or print direct: System.out.println(days*24*60*60) And DO NOT print any additional text like " converting days to.... ". This will produce an error for the CodeCoach. Print ONLY the number of result.
8th Nov 2021, 12:55 PM
Coding Cat
Coding Cat - avatar
0
Ok ..I will try it...
8th Nov 2021, 2:22 PM
Meghna Som
0
How to fix this I copy and paste your code and run it. Then I change this lines: Import java.util.Scanner; public class program{ Public static void main(String []args) I changed "Import" to "import" and "Public" to "public". Then run it. The code works without any problems. What is the issue?
8th Nov 2021, 6:08 PM
Мария Антонова
Мария Антонова - avatar
0
First of all, you don't have to expand the mechanism int dayToHour= days*24; /* 1day=24hour */ int dayToMintue = dayToHour*60; /* 1hour=60min */ int dayToSecond = dayToMintue*60; /* 1min=60 sec */ like this Instead of that, you can simply convert days to seconds using daysToSecond = days * 24 * 60 * 60 ( you have to declare a new variable I'm using int daysToSecond) fist step - days * 24 means, convert days into 24 hours if you enter 12 days it multiplies with 24 so then you can get how many hours second step - days * 24 * 60 means converting the hours into minutes 12 days * 24 = 288 if we multiply 288 hours with 60 we can get 17280 in minutes third step - days * 24 * 60 * 60 means converting the minutes into seconds finally, if you multiply 17280 minutes with 60 we can get 1036800 in seconds which means 12 days = 1036800 seconds The new code is right below enjoy ;) public class Main { public static void main(String[] args) { System.out.println("Enter the days"); Scanner sc = new Scanner (System.in); int days = sc.nextInt(); //new code int daysToSecond = days * 24 * 60 * 60 ; System.out.println("converting days to second: " + daysToSecond); } }
9th Nov 2021, 10:32 AM
Ashina Shanuka
Ashina Shanuka - avatar
- 1
What is the problem with your code? What is your expected output? Save code and share link here.. You can write directly like : days*24*60*60 ,then no need of variables.
8th Nov 2021, 9:53 AM
Jayakrishna 🇮🇳
- 1
I also tried this .... Like: Int second = days*24*60*60; But it couldn't run .. It's show me a bugs ...
8th Nov 2021, 10:11 AM
Meghna Som