0

Time converter bug for end of module 10

The project is to convert days to seconds by using basic algebra in tangent with what you are learning. However the program is changing my results, I've tested this by only giving it the answers without any math by the following method num1=x and then printing num1 out. The math worked for the one output but not for the second and vice versa which forced me to try just giving it the solutions without the math. When I gave it the solutions it was saying my outputs were wrong by a few hundred but how can that be when there's no math for it to go wrong out. Int num1 = 178200; Int num2 = 4579200; System.out.printIn(num1+num2); The expected outcome should be 178200 4579200 but it keeps changing the second output to 4575200

14th Feb 2021, 1:39 PM
M͢a͢t͢t͢h͢e͢w͢ M͢u͢rd͢o͢c͢k͢
10 Answers
+ 1
M͢a͢t͢t͢h͢e͢w͢ M͢u͢rd͢o͢c͢k͢ This is not right code. You have to write program but you are printing hard coded value. This is a simple program to convert days in seconds.
14th Feb 2021, 1:48 PM
A͢J
A͢J - avatar
+ 1
Hi! it would be easier to help you if there was a link to your code attached here
14th Feb 2021, 1:49 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 1
14th Feb 2021, 1:55 PM
A͢J
A͢J - avatar
+ 1
M͢a͢t͢t͢h͢e͢w͢ M͢u͢rd͢o͢c͢k͢ 12 days is just an example. There may be different days for different test cases so you have to take input from user. Use Scanner class to take input from user.
14th Feb 2021, 2:18 PM
A͢J
A͢J - avatar
0
I am AJ! I understand that it was a hardcoded value I explained why I even tested it like that. I know that the idea was to create the actual working code but when I did so the values weren't coming out just right even though I used a regular calculator to verify the math that's when I decided to just give the hard value and low and behold they still got changed in the output
14th Feb 2021, 1:54 PM
M͢a͢t͢t͢h͢e͢w͢ M͢u͢rd͢o͢c͢k͢
0
I am AJ! It's overwritten right now with the hardcoded version however this is what I added to what existed already: Int num1 = 12; Int num2 = 24; Int num3 = 60; Int num4 = 265; Int sum1; Int sum2; Int newSum1; sum1 = num1 * num2 * num3; newSum1= sum1 * 10; sum2 = sum1 * num4; System.out.printIn(newSum1+sum2);
14th Feb 2021, 2:02 PM
M͢a͢t͢t͢h͢e͢w͢ M͢u͢rd͢o͢c͢k͢
0
M͢a͢t͢t͢h͢e͢w͢ M͢u͢rd͢o͢c͢k͢ This is not right. You have to take days from user and convert to second like int seconds = days * 24 * 60 * 60; Where 24 hours, 60 minutes and 60 seconds There are different test cases given so every time output will change on different input
14th Feb 2021, 2:14 PM
A͢J
A͢J - avatar
0
I am AJ Why was it saying I needed to work with 12 days then? Alternatively doing it the 12*24*60*60 would go way beyond the output answer that it needed? That's why I skipped the last 60 and did the math for the correct output values that it needed instead.
14th Feb 2021, 2:17 PM
M͢a͢t͢t͢h͢e͢w͢ M͢u͢rd͢o͢c͢k͢
0
I am AJ Ok I'll try again actually working through the problem again however my original question still remains: if it's looking for a specific answer with x amount of output and I gave it as a hard coded value why was it changing when there was nothing to change it?
14th Feb 2021, 2:24 PM
M͢a͢t͢t͢h͢e͢w͢ M͢u͢rd͢o͢c͢k͢
0
Hello AJ or Matthew What do you think about this ... Int num1 = 12 days Int num2 = 12 * 24 = 288 hours Int num3 = 288 * 60 = 17280 minutes Int num4 = 17280 * 60 = 1036800 seconds); check out
28th Aug 2021, 12:51 AM
Mario Julian Ramon Montoya
Mario Julian Ramon Montoya - avatar