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 the name used for the camera s view from a single position?
CaHeK987 [17]
The answer to your question is a shot


6 0
3 years ago
Help me please, I'm attempting a test<br>​
dusya [7]
It’s A it’s a keyboard
8 0
2 years ago
Read 2 more answers
What report provides data on how specific sections of a website performed?
zalisa [80]

Answer:What report provides data on how specific sections of a website performed? 100% Correct Answer: Content Drilldown report

Explanation: sorry if it’s wrong

3 0
2 years ago
Joe, a user, wants his desktop RAID configured to allow the fastest speed and the most storage capacity. His desktop has three h
kirill115 [55]

Answer:

A. 0

Explanation:

The technician should configure the RAID 0 for Joe.

RAID 0 also referred to as the striped volume or stripe set is configured to allow the fastest speed and the most storage capacity by splitting data evenly across multiple (at least two) disks, without redundancy and parity information.

Also, RAID 0 isn't fault tolerant, as failure of one drive will cause the entire array to fail thereby causing total data loss.

7 0
3 years ago
In this lab, 172.30.0.0 represents the __________ network and 10.20.1.0 represents the _________ network.
umka21 [38]
172.30.0.0: private network
10.20.1.0: public network
6 0
3 years ago
Other questions:
  • What’s some WiFi passwords for some big brands that I can connect to while traveling?
    7·1 answer
  • What do you call a set of programs?
    7·1 answer
  • What quantities are measured by the following sensors:
    9·1 answer
  • Software enables users to create documents
    13·1 answer
  • Which is an example of synchronous communication?
    9·2 answers
  • What is the web of trust
    7·2 answers
  • Draw a dfd that shows how data will be stored, processed, and transformed in the tims system
    9·1 answer
  • What is an orthochromatic film?
    12·1 answer
  • A game developer is purchasing a computing device to develop a game and recognizes the game engine software will require a devic
    7·1 answer
  • What is malware? a type of virus that spreads through a network connection a type of virus that targets programs and files any p
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!