Ask Question
18 August, 19:09

Assume that name and age have been declared suitably for storing names (like "Abdullah", "Alexandra" and "Zoe") and ages respectively. Write some code that reads in a name and an age and then prints the message "The age of NAME is AGE." where NAME and AGE are replaced by the values read in for the variables name and age. For example, if your code read in "Rohit" and 70 then it would print out "The age of Rohit is 70.".

+4
Answers (1)
  1. 18 August, 19:43
    0
    import java. util. Scanner;

    public class num2 {

    public static void main (String[] args) {

    Scanner in = new Scanner (System. in);

    System. out. println ("Enter Name");

    String name = in. next ();

    System. out. println ("Enter Age");

    int age = in. nextInt ();

    System. out. println ("The age of "+name + " is "+age);

    }

    }

    Explanation:

    Java programming language is used to write the code.

    The scanner class is used to prompt and receive values for name and age which are stored in the appropriate variables.

    The key idea here is using string concatenation in the output statement in order to print the desired output
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Assume that name and age have been declared suitably for storing names (like "Abdullah", "Alexandra" and "Zoe") and ages respectively. ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers