1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Nikolay [14]
2 years ago
8

Assume that name and age have been declared suitably for storing names (like "Abdullah", "Alexandra" and "Zoe") and ages respect

ively. 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", on a line by itself. There should not be a period in the output.
Computers and Technology
1 answer:
shutvik [7]2 years ago
3 0

Answer:

I will write the code in C++ and JAVA                    

Explanation:

<h2>C++ Program:</h2>

#include <iostream>

using namespace std;

int main()

{ std::string NAME;  

// i have used std::string so that the input name can be more than a single character.

std::cout << " enter the name"; // take an input name from user

std::getline(std::cin,NAME);

int AGE;

       cout<<"Enter age";  //takes age from the user as input

       cin>>AGE;

   cout<<"The age of "; std::cout <<NAME; cout<< " is " << AGE; }

/* displays the message for example the name is George and age is 54 so    message displayed will be The age of George is 54 and this will be displayed without a period */

<h2>Explanation:</h2>

The program first prompts the user to enter a name and the asks to input the age of that person. As per the requirement the if the user enter the name George and age 54, the program displays the following line as output:

The age of George is 54

Here  std::string is used so that the input string can be more than one character long.

<h2>JAVA code</h2>

import java.util.*;

public class Main

{ public static void main(String[] args) {

String NAME;

Scanner sc = new Scanner(System.in);

System.out.println("Enter a name:");

NAME= sc.nextLine();

int AGE;

Scanner scanner = new Scanner(System.in);

System.out.println("Enter age:");

AGE = Integer.parseInt(scanner.nextLine());

System.out.print("The age of " + NAME + " is " + AGE); }}

<h2>Explanation:</h2>

This is the JAVA code which will work the same as C++ code. The scanner class is used to read the input from the user. The output of the above JAVA code is as follows:

Enter a name: George

Enter age: 45

The age of George is 45

You might be interested in
Write a declaration of a variable named count that can be used to hold numbers like 90000 and -1 and -406.
Andreyy89
Which language? In Java it would simply be:

int count;
7 0
2 years ago
When virtualization is used and bare-metal solutions are implemented, what is the item that resides between the virtual machines
Yakvenalex [24]

That's the hypervisor.

6 0
3 years ago
Read 2 more answers
What is a very important difference there between the wiring of an electromechanical thermostat and an electronic programmable t
valentinak56 [21]

Answer:

A mechanical thermostat will typically use a bimetal strip with two different metals that expand/contract with the temperature at different rates.

Explanation:

7 0
2 years ago
Time shifting occurs when
Aleksandr-060686 [28]
Answer: C

Time shifting is when you move from one period in time to another.
4 0
3 years ago
Read 2 more answers
In this exercise, your function will receive 2 parameters, the name of a text file, and a list of strings. The function will wri
diamong [38]

Answer:

# the function is defined

# it takes 2 arguments: filename and list of string

def solution(filename, listOfString):

   # the file is opened in write mode

   # so that we can write to it

   with open(filename, 'w') as file_object:

       # we loop through the entire list of string

       # this looping help us know what to write to the file

       for each_string in listOfString:

           # if the length of the string is less than 4

           # we write 'x' with a new line

           if len(each_string) < 4:

               file_object.write("x\n")

           # else if the length of the string is greater than equals 4

           # we write the fourth character

           # and also add new line

           else:

               file_object.write(each_string[3])

               file_object.write("\n")

Explanation:

The function is written in Python. It takes two argument; filename and list of string.

It opens the file in write mode and then loop through the list of string. During the loop, we know what to write to the file.

In the length of a string is less than 4; we write 'x' else we write the fourth character in the string. The fourth character has an index of 3 because string uses zero index counting like a string. Starting from zero; 0, 1, 2, 3, 4... the fourth character has an index of 3.

5 0
3 years ago
Other questions:
  • Mobile devices typically come pre installed with standard apps like web browsers , media players, and mapping programs true or f
    9·1 answer
  • What is A/B Testing
    10·2 answers
  • How many questions must you answer in Brainly to be able to message people?
    6·2 answers
  • Select all that apply.
    10·1 answer
  • Define the terms of data and information .​
    6·1 answer
  • What are the things that a computer literate understands?Name thems.​
    14·1 answer
  • You do not really know that you have a hand. Here is why. Imagine the possibility in which you are only a handless brain floatin
    14·1 answer
  • Primary storage is electronic storage connected directly to the CPU. true or false​
    9·1 answer
  • A social service agency hires accenture to improve training and experiences for caseworkers. What is one way accenture can use v
    12·1 answer
  • What is the purpose of the GETPIVOTDATA function?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!