Ask Question
13 April, 15:26

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

+5
Answers (1)
  1. 13 April, 15:36
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers