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
maksim [4K]
3 years ago
5

This function receives first_name and last_name, then prints a formatted string of "Name: last_name, first_name" if both names a

re not blank, or "Name: " with just one of the names, if the other one is blank, and nothing if both are blank.
Computers and Technology
1 answer:
pishuonlain [190]3 years ago
3 0

Answer:

Following are the program in the C++ Programming Language.

//set header file

#include <iostream>

//set namespace

using namespace std;

//define class

class format

{

//set access modifier

public:

//set string type variable

 string res;

//define function

 void names(string first_name, string last_name)

 {  

//set if-else if condition to check following conditions

   if(first_name.length()>0 && last_name.length()>0)

   {

     res="Name: "+last_name+", "+first_name;

   }

   else if(first_name.length()>0 and last_name.length()==0)

   {

     res="Name: "+first_name;

   }

   else if(first_name.length()==0 and last_name.length()==0)

   {

     res="";

   }

 }

//define function to print result

 void out(){

   cout<<res<<endl;

 }

};

//define main method

int main() {

//set objects of the class

 format ob,ob1,ob2;

//call functions through 1st object

 ob.names("John","Morris");

 ob.out();

//call functions through 2nd object

 ob1.names("Jhon","");

 ob1.out();

//call functions through 3rd object

 ob2.names("", "");

 ob2.out();

}

<u>Output</u>:

Name: Morris, John

Name: Jhon

Explanation:

<u>Following are the description of the program</u>:

  • Define class "format" and inside the class we define two void data type function.
  1. Define void data type function "names()" and pass two string data type arguments in its parameter "first_name" and "last_name" then, set the if-else conditional statement to check that if the variable 'first_name' is greater than 0 and 'last_name' is also greater than 0 then, the string "Name" and the following variables added to the variable "res". Then, set else if to check that if the variable 'first_name' is greater than 0 and 'last_name' is equal to 0 then, the string "Name" and the following variable "first_name" added to the variable "res".
  2. Define void data type function "out()" to print the results of the variable "res".
  • Finally, we define main method to pass values and call that functions.
You might be interested in
Under extreme programming, ________ and ________ are intimately related parts of the same process
Inessa05 [86]
The answer to this question is: coding and testing
Extreme programming is a software development methodology that aim to improve software quality by measuring whether the technology can be used to fulfill customer's requirement.
To actually get somethings that is accepted by the customers, various coding and testing the software will be done constantly
8 0
3 years ago
Read 2 more answers
A hard drive that is running slowly may not have been
Anuta_ua [19.1K]
Plugged in i think is the answer
7 0
3 years ago
Read 2 more answers
Professional photographers often use the lowest quality settings on their cameras since this can be reversed in Photoshop.
kap26 [50]
False you want to use the best lenses and settings as very fine details can't be edited plus let's be real no one wants to sit for three hours editing one photo 
3 0
3 years ago
Read 2 more answers
Where does change management play a major role in transforming a client
nevsk [136]

To manage a modern IT environment characterized by hybrid complexity and exponential data growth — and to make that same IT a driver of growth and innovation for the business — you need to build intelligence into every layer of your infrastructure.

3 0
3 years ago
Which piece of personal information do websites often require users to enter?
Tatiana [17]
<h2>Answer: <u><em>The most common type of information that a website will ask you for is a password, which is unique to that site. Eye color is irrelevant for sites since there are only about 5 possible colors for human eyes. Most of the time there is no practical use for that information.</em></u></h2>

Explanation:

<h2><u><em>Hope this helps</em></u></h2>
7 0
3 years ago
Read 2 more answers
Other questions:
  • Marie uses a browser to visit a blog. What is the unique identifier of the blog?
    13·2 answers
  • In 2-3 paragraphs, identify at least two ways technology and innovation have affected global economic competition. Provide a spe
    5·1 answer
  • Find the 65th percentile from the data. The data consist of class interval from 0-10, 10-20, 20-30, 30-40, 40-50, 50-60 and freq
    8·1 answer
  • Which of the following types of access controls do not describe a lock? (a)- Directive (b)- Physical (c)- Preventative (d)- Dete
    8·1 answer
  • which type of classroom enable students to attend lectures without being physically present with the teacher
    14·2 answers
  • When using correct ergonomic technique be sure to
    6·2 answers
  • What are the two types of lighting?
    7·2 answers
  • Write a complete Java program called Stewie2 that prints the following output. Use at least one static method besides main. ////
    9·2 answers
  • A(n) ____________________ is hardware or software that blocks or allows transmission of information packets based on criteria su
    13·1 answer
  • Describe risk avoidance. Name three common methods of risk avoidance.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!