Answer:
import java.util.Scanner;
public class num14 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter a Name");
String name = input.next();
System.out.println("Enter the age");
int age = input.nextInt();
//Calling the Method
displayNameAge(name,age);
}
public static void displayNameAge(String name, int age){
System.out.println("The name is "+name+". The age is "+ age);
}
}
Step-by-step explanation:
Using Java Programming language:
- Firstly create a method called displayNameAge() That accepts two parameter a string for name and an int for age
- The method uses string concatenation to produce the required output
- In a main method the scanner class is used to prompt user to enter values for name and age. These are stored in two seperate variable
- The method displayNameAge() is then called and passed these values as arguments.