Age Learn programming Java

Lesson:

First contact with Java


Exercise:

Age


Objetive:

Write a java program to ask the user for their age (e.g. 20) and respond with something like "You look younger than 20" (the age entered by the user should be displayed in place of "20").


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);
	}
}

Juan A. Ripoll - Systems Tutorials and Programming Courses ©  All rights reserved.  Legal Conditions.