Age Learn programming Java

Lesson:

First contact with Java


Exercise:

Age 7


Objetive:

Write a java program to ask the user for his age (20, for instance) and answer something as "You look younger than 20" (instead of 20, you should display the age that has been entered).


Code:

import java.util.*;
public class Main
{
	public static void main(String[] args)
	{
		int age;
		System.out.print("Enter a age ");
		age = Integer.parseInt(new Scanner(System.in).nextLine());
		System.out.printf("You look younger than %1$s ", age);
	}
}