-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAge.java
29 lines (25 loc) · 1011 Bytes
/
Age.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import java.util.Scanner;
public class Age {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Please enter your age in years: ");
int age = in.nextInt();
int years = age;
int months = years * 12;
int weeks = months * 54;
int days = weeks * 365;
int hours = days * 24;
long minutes = hours * 60L;
long seconds = minutes * 60L;
long milliseconds = seconds * 1000L;
System.out.printf("Your age in years: %,d \n", years);
System.out.printf("Your age in months: %,d \n", months);
System.out.printf("Your age in weeks: %,d \n", weeks);
System.out.printf("Your age in days: %,d \n", days);
System.out.printf("Your age in hours: %,d \n", hours);
System.out.printf("Your age in minutes: %,d \n", minutes);
System.out.printf("Your age in seconds: %,d \n", seconds);
System.out.printf("Your age in milliseconds: %,d \n", milliseconds);
in.close();
}
}