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
ANSWER QUICKLY!!! <br><br> What is an advantage of digital portfolios?
algol13
Easy to carry or utilize
8 0
2 years ago
. Use one command to create a /sales directory with the permissions of 770
mars1129 [50]

Answer:

mkdir -m 770 sales

Explanation:

The command mkdir is used to create a directory and the attribute or flag

-m is used to  assign permissions on create a folder.

Example:

mkdir -m 770 sales

Create a folder with permissions 770 with name sales

7 0
3 years ago
Shift all elements by one to the right and move the last element into the first position. For example, 1 4 9 16 25 would become
guajiro [1.7K]

Answer:

i see you but i dobt see it

Explanation:

8 0
3 years ago
Qbasic program to convert Nepali rupees into paisa​
Svetradugi [14.3K]

Answer:

INPUT "What is the amount of rupees you want converted into paisa"; rupees

paisa = rupees*100

PRINT paisa

Explanation:

done in QBASIC
the semicolon in the 1st line makes the question have a ? at the end. the rupees key word in the 1st line saves the input as a variable

then the second line multiplies by 100 since there are 100 paisa in 1 rupee

5 0
2 years ago
Linux is a kind of software whose code is provided for use, modification, and redistribution. what kind of software is this?
Leni [432]
<span>Linux is a type of open-source software. The entire premise of open-source code is to make it as easy for people to develop and share as possible, instead of use as a vehicle to make money. This way, the collective knowledge of the community can make the program as secure and user-friendly as possible.</span>
7 0
3 years ago
Other questions:
  • If you were asked to subnet a network in such a way as to arrive at 6 network ids you would need to borrow 2 bits.
    7·1 answer
  • Why is it important to minimize cable clutter in a rack?
    11·1 answer
  • 4. Write an appropriate comment for describ-
    11·1 answer
  • 11.19 (Constructor Failure) Write a program that shows a constructor passing information about constructor failure to an excepti
    6·1 answer
  • The advantage of returning a structure type from a function when compared to returning a fundamental type is that
    5·1 answer
  • Pixar is a company that creates a huge amount of images, audio recordings, and videos, and they need to decide what compression
    11·1 answer
  • I just logged onto brainly and all my questions were deleted and i lost 2 brainliest. What has brainly done to my account I also
    6·2 answers
  • Rom a game design perspective, including some risks in your game can help make it both exciting and challenging, but also what e
    15·1 answer
  • What equipment allows a computer to connect to the internet.
    13·1 answer
  • How to set horizontal text alignment​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!