¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita+ 3
What does java do?
what does java do like i cant do anything with that i find this code and do nothing whyyyy 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 sec = days * 24 * 60 * 60; System.out.println(sec); } }
7 Respuestas
+ 2
It seems you joined the Web Development course only. And to my knowledge, Java is not covered in that course.
The code you "found" is valid.
If you are interested in Java, you can start with the Introduction to Java course.
+ 2
Alberto Iannucci thanks bro 😊
+ 2
Anoryne Wafula thanks bro:)
+ 1
this code seems to be okay...
+ 1
This code takes an input(days) and print the number of seconds. e.g: when you give a input 1 day it returns the total numbers of seconds in that number of day. It multiplies the number of day with 24 hours and then convert it to 60 minutes and then convert it to seconds.
+ 1
import java.util.Scanner;
public class Program {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the number of days: ");
int days = scanner.nextInt();
int sec = days * 24 * 60 * 60;
System.out.println("The number of seconds in " + days + " days is: " + sec + " seconds");
scanner.close(); // Close the scanner to prevent resource leaks
}
}
With this code, when you run the program, it will prompt you to enter the number of days. Once you enter the number and press “Enter,” the program will calculate the total number of seconds corresponding to the input days and print it to the screen.
Make sure to enter an integer when prompted, otherwise the program might throw errors. After entering the number of days and pressing “Enter,” you should see the corresponding result in seconds printed to the screen.
+ 1
Java is an object oriented programming language used to do the following:
building desktop applications.
Building mobile Android applications.
You could as well learn it as a general-purpose programming language
If you want to work on large enterprise software applications, then java is good for you.