Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a Java program to do the following: Input a first name Input a last name I

ID: 3909009 • Letter: W

Question

Write a Java program to do the following: Input a first name Input a last name Input an age in years (First and last name must be input separately at run time) Calculate the following information (using Java) based on the age in years: Age in months. Age in days. Age in hours. Age in minutes. Age in seconds. Display the following: (Last name), (First name) (# of years old) years old. (# of months old) months old. (# of days old) days old. (# of hours old) hours old. (# of minutes old) minutes old. (# of seconds old) seconds old.

Explanation / Answer

import java.util.Scanner; public class AgeDetails { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter your first name: "); String firstName = in.next(); System.out.print("Enter your last name: "); String lastName = in.next(); System.out.print("Enter your age in years: "); int age = in.nextInt(); System.out.printf("%s, %s %d years old. %d months old. %d days old. %d hours old. %d minutes old. %d seconds old. ", lastName, firstName, age, age*12, age*365, age*365*24, age*365*24*60, age*365*24*60*60); } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote