package pl.pp; import java.util.Scanner; public class AgeInSeconds { public static void main(String[] args) { // Create a Scanner object to read input Scanner scanner = new Scanner(System.in); // Ask the user for their age in years System.out.print("Enter your age in years: "); int ageInYears = scanner.nextInt(); // Close the scanner to prevent resource leak scanner.close(); // Calculate the age in seconds long ageInSeconds = (long) ageInYears * 365 * 24 * 60 * 60; // Display the age in seconds with proper description System.out.println("My age in seconds: " + ageInSeconds); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter