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
What is one current method of detecting planets orbiting around other stars?
Gnoma [55]
C

D is the old way.

A they have not done yet

B not even a thing
5 0
3 years ago
. What projects would Excel best be used for?
adoni [48]

Answer:

Projects that require spreadsheet organization and/or calculations between data

Explanation:

That is why Excel is a spreadsheet program

7 0
2 years ago
. The BEST description of a proprietary database is one that
AVprozaik [17]
Is free to the public
8 0
3 years ago
Any help , and thank you all
Paladinen [302]

Answer:

There are 28 chocolate-covered peanuts in 1 ounce (oz). Jay bought a 62 oz. jar of chocolate-covered peanuts.

Problem:

audio

How many chocolate-covered peanuts were there in the jar that Jay bought?

Enter your answer in the box.

Explanation:

3 0
3 years ago
Please can someone help my assignment.​
sweet [91]

Answer:

my hero academia fan!!!!!!

5 0
3 years ago
Other questions:
  • According to the appendix what was the purpose of newspeak
    12·1 answer
  • For every decision you make, there is a trade-off. Please select the best answer from the choices provided T F
    12·2 answers
  • When you are printing handouts, which of these can you do? A. Save paper by placing more than one slide per page. B. Check the f
    7·1 answer
  • Enables you to temporarily hide all the open windows except the one you are viewing.
    11·1 answer
  • Use the drop-down menus to complete the statements about message marking, categorizing, and flagging.
    13·2 answers
  • Differentiate between system software and application software
    13·2 answers
  • Write if true or false
    12·1 answer
  • Miley met up with a bunch of her college friends after several years. She told them that she works for the sound department of a
    5·1 answer
  • This site isn't letting me add my ans and wut should I do?
    15·1 answer
  • During the data transmission there are chances that the data bits in the frame might get corrupted. This will require the sender
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!