1, a java program that ask the user for their name and the year they were born. Display the name of the user and their age in years.
//YearToAge.java import java.util.Scanner; public class YearToAge { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print("Enter name: "); String name = scanner.nextLine(); System.out.print("Enter year you born: "); int year = scanner.nextInt(); int age = 2020-year; System.out.println(name+" is "+age+" years old"); } }
Get Answers For Free
Most questions answered within 1 hours.