 Please! i'm new!! I need help with a time Converter code!! | SoloLearn: Learn to code for FREE!

+4

# 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*/

+7

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

+4

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?

+4

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); } }

+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

+2

Calculate number of seconds in one day first, then multiply that by number of days ... int dayToSeconds = 86400; // 24 * 60 * 60 int result1 = 2 * dayToSeconds; int result2 = 53 * dayToSeconds;

+2

Are you supposed to take input for number of days?

+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); } }

+1

Save your code in SoloLearn and share the link here so I can take a look. Posting code as raw text is rather hard to read. No highlighting, nor line numbers : ) https://www.sololearn.com/post/75089/?ref=app

+1

Аракет аракет анан дагы аракет!

+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 } }

+1

Solution kya hai bhai batao

+1

Hii I was also having problem but this is my answer:- import java.util.Scanner; class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int days = scanner.nextInt(); int a = (days); int b = 24; int c = 60; int d = 60; int test_case_1 = a*b*c*d; System.out.println(test_case_1); } }

+1

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); } }

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

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

0

If i put System.out.println(result1)(result2) it says: ";" is missing

0

In the code yes, but the result must be in seconds

0

Okay maybe you need to read the input twice. int days = scanner.nextInt(); // multiply this by dayToSeconds // print the result days = scanner.nextInt(); // repeat multiplication with this // and print the result Try it and let me know ...

0

It shows me an error on Java Main. :C

0

Ok i don't know.. i quit.. thanks a Lot bro!