Ask Question
12 September, 15:43

Write some code that reads in a name as a string and an age as an integer into the variables name and age. It then prints the message "The age of NAME is AGE" on a line by itself, where NAME and AGE represent the values read into the variables name and age respectively. For example, if your code read in "Rohit" and 70 then it would print out "The age of Rohit is 70" on a line by itself. There should NOT be a period in the output. Use the up or down arrow keys to change the height.

+1
Answers (1)
  1. 12 September, 17:42
    0
    Following are the code to this question:

    import java. util.*; //import package

    public class Main//defining class Main

    {

    public static void main (String[] as) / /defining main method

    {

    Scanner obx = new Scanner (System. in); //creating Scanner class Object

    String name = obx. next (); //input String value in name variable

    int age = obx. nextInt (); //input integer value in age variable

    System. out. println ("The age of " + name + " is " + age); //print value with message

    }

    }

    Output:

    Rohit

    70

    The age of Rohit is 70

    Explanation:

    The description of the given java code can be defined as follows:

    In the above java code, two-variable "name and age " is declared, in which name is string variable and age is an integer variable. In the next step, the scanner class object is created, in which we input values in the variable and use the print method to print its value with the message.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write some code that reads in a name as a string and an age as an integer into the variables name and age. It then prints the message "The ...” 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