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
Calculate the addition and multiplication of N integers numbers read from the keyboard
Viefleur [7K]
F,ELSE,FR,D,WHLE I think this is the correct answer. your quiestion is really confusing. also please make me the brainiest and correct me if im wrong.
6 0
3 years ago
What a true portrait reveal
Snowcat [4.5K]
Is simple likeness. Historically, in fact, artists used self-portraits as a kind of calling card, attesting to their ability to capture a likeness and giving a sense of their capabilities. And, yes, self-portraits are convenient exercises because the model is always available and works for free
5 0
3 years ago
How many bits must be “flipped” (i.e., changed from 0 to 1 or from 1 to 0) in order to capitalize a lowercase ‘a’ that’s represe
Neporo4naja [7]

<span>To capitalize lowercase “a” which is 0110001 which is “A” you will need to flip the following bites 01000001<span> as represented in ASCII. Since we are only looking at 2bit digit which is 0 and 1 which  has a 256 possible combinations from 0 up to 255. </span></span>


6 0
3 years ago
you want to be able to restrict values allowed in a cell and need to create a drop-down list of values from which users can choo
STALIN [3.7K]

The  feature to restrict values allowed in a cell and need to create a drop-down list of values from which users can choose in the above scenario is data validation.

<h3>What is data validation?</h3>

Data validation is a term that connote the act of monitoring the truthfulness and quality of source data before one can make use of it, importing or even  process data with it.

Note that The  feature to restrict values allowed in a cell and need to create a drop-down list of values from which users can choose in the above scenario is data validation as it ensure that users can make their own choice.

Learn more about data validation from

brainly.com/question/27138101

#SPJ1

8 0
3 years ago
The difference between tool bar and status bar​
Snowcat [4.5K]

Answer:

A toolbar offers easier access to tasks typically conducted within the application whereas in the status bar it is displayed at the lower side of the web browser screens and other application windows.

Explanation:

8 0
2 years ago
Other questions:
  • Angela wrote some lines of code that she wants to test. She will need to use __________. IDLE open source a prompt a file path
    15·2 answers
  • What are some innovations that a cell phone has undergone since its original invention?
    14·1 answer
  • What is a organisation in office technology
    7·1 answer
  • In the Remote Access Domain, if private data or confidential data is compromised remotely, you should set automatic blocking for
    15·1 answer
  • Write a program that displays a menu allowing the user to select air water, or steel. After the user has made a selection, the n
    10·1 answer
  • Write a function to prompt the user to enter the information for one movie (title, release date, mpaa rating and number of stars
    8·1 answer
  • How many strings with five or more characters can be formed from the letters in seeress?
    15·1 answer
  • CSCU EXAM TEST FINAL1-A software or hardware that checks information coming from the Internet and depending on the applied confi
    6·1 answer
  • What is the difference between cyberbullying and bullying.
    5·2 answers
  • What is the difference between * and **operator? in python ​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!