+ 3

Please! i'm new!! I need help with a time Converter code!!

Hi guys! I'm new here and i'm new programing, so please, can someone help me with that code? It's a Java time Converter! I must convert 2 days in seconds and 53 days in seconds, the code is ok but i don't know how put twice results!! I only can print the first problem but i don't know how resolve the second one! I have the awnser but i can put in! The program don't recognize My second awnser!! Here is the code: import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int days = scanner.nextInt(); //tu código va aquí int a = 2; int b = 24; int c = 60; int d = 60; int sum1 = a*b; int sum2 = sum1*c; int sum3 = sum2*d; System.out.println(sum3); } } /*How can I answer both exercises? Thanks*/

28th Nov 2020, 9:05 AM
Lordakia Santiago
Lordakia Santiago - avatar
48 ответов
+ 8
Hi, Try this code and it will help pass both answers import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int days = scanner.nextInt(); int daysToSeconds = days * 24 * 60 *60; System.out.println(daysToSeconds); } } It works for me, let me know if it works also with you?
29th Nov 2020, 9:22 PM
Mohamed Sweify
Mohamed Sweify - avatar
+ 7
Lordakia Santiago This was your code right? I just commented out int a = 2 ( why did you need it?) and changed sum1 = days * b. This is working. import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int days = scanner.nextInt(); //tu código va aquí //int a = 2; int b = 24; int c = 60; int d = 60; //int sum1 = a*b; int sum1 = days * b; int sum2 = sum1*c; int sum3 = sum2*d; System.out.println(sum3); } }
30th Nov 2020, 1:03 AM
Minho
Minho - avatar
+ 6
Lordakia Santiago You got it wrong! There is just one input, which is the number of days. int days = scanner.nextInt(); [ No more input needed except this. ] And you need to convert that days into seconds. So the result is, days * 24 * 60 * 60
29th Nov 2020, 12:36 PM
Minho
Minho - avatar
+ 5
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 int hours = days * 24; int minutes = hours * 60; int seconds = minutes * 60; System.out.print(seconds); } }
31st Dec 2020, 3:54 AM
ashvin vanol
ashvin vanol - avatar
+ 3
Are you supposed to take input for number of days?
28th Nov 2020, 9:34 AM
Ipang
+ 3
Lordakia Santiago, don't feel so because you inspired me first, i was stacked at the same point and finding your post inspired me to find the solution ;), have a nice day
30th Nov 2020, 7:43 AM
Mohamed Sweify
Mohamed Sweify - avatar
+ 3
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 int h=days*24; int min=h*60; int sec=min*60; System.out.println(sec); } }
22nd May 2021, 7:44 PM
sirine elayari
+ 2
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int days = scanner.nextInt(); int second = 0; //your code goes here second = days * 24 * 60 * 60; System.out.println(second); } }
24th Jan 2021, 9:47 AM
Mutlu Eren
Mutlu Eren - avatar
+ 2
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int days = scanner.nextInt(); int sec; sec = days*86400; System .out .print (sec); } }
16th May 2021, 5:55 AM
Ahmad Zherati
Ahmad Zherati - avatar
+ 2
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 int hours = days * 24; int minutes = hours * 60; int seconds = minutes * 60; System.out.print(seconds); } }
20th Dec 2021, 3:54 AM
MN FATHIMA RIHAM - s92064451 -321424451
MN FATHIMA RIHAM - s92064451 -321424451 - avatar
+ 1
And thanks You anyway
29th Nov 2020, 5:47 PM
Lordakia Santiago
Lordakia Santiago - avatar
+ 1
Mohamed Sweify: Man!!! You did it!!! The input value was already defined in "days" i did not put new ones! I just only need to do the operation!
30th Nov 2020, 4:09 AM
Lordakia Santiago
Lordakia Santiago - avatar
+ 1
Аракет аракет анан дагы аракет!
30th Nov 2020, 8:01 AM
Талгат Садырбеков
Талгат Садырбеков - avatar
+ 1
Mohamed Sweify, Are you an Indian guy who solves IT problems? I just appreciate you, bro. Your answers really work out.
31st Dec 2020, 2:12 PM
Weician Htet
Weician Htet - avatar
+ 1
Solution kya hai bhai batao
3rd Jan 2021, 9:18 AM
Haritap Kumar
Haritap Kumar - avatar
+ 1
import java.util.*; public class Exercise55 { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Input seconds: "); int seconds = in.nextInt(); int p1 = seconds % 60; int p2 = seconds / 60; int p3 = p2 % 60; p2 = p2 / 60; System.out.print( p2 + ":" + p3 + ":" + p1); System.out.print("\n"); } }
29th Mar 2021, 8:47 AM
Manish Yadav
Manish Yadav - avatar
+ 1
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 int hours = days * 24; int minutes = hours * 60; int seconds = minutes * 60; System.out.print(seconds); } }
17th Aug 2021, 10:38 AM
Vraj Soni
Vraj Soni - 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(); //tu código va aquí int dayToSeconds = 86400; // 24 * 60 * 60 int result1 = 2 * dayToSeconds; int result2 = 53 * dayToSeconds; System.out.println(result1); System.out.println(result2); } } Bro, i put it already but still doesnt work! :c
28th Nov 2020, 9:29 AM
Lordakia Santiago
Lordakia Santiago - avatar
0
the program takes my 2 answers as one! and it gives me results: 172800 4579200 But it need awnser two questions! Not one :c
28th Nov 2020, 9:32 AM
Lordakia Santiago
Lordakia Santiago - avatar
0
If i put System.out.println(result1)(result2) it says: ";" is missing
28th Nov 2020, 9:34 AM
Lordakia Santiago
Lordakia Santiago - avatar