Ask Question
3 March, 19:15

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.".

+2
Answers (1)
  1. 3 March, 22:28
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers