Display your name, age and city name

How to display your name, age and city name in Java

Write a program to display your name, your age and your city name on screen in three different lines.

Expected Output:

My name is your name
I am your age years old.
I am from your city name

Java code to print name, age and city on screen:
public class DisplayYourNameJava {

    public static void main(String[] args) {
        System.out.println("I am John Baker");
        System.out.println("I am 34 years old");                                                                  
        System.out.println("I am from Leeds");
    }
    
}
Output:
I am John Baker
I am 34 years old
I am from Leeds        

1 comment :