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
In a car crash, wearing a seat belt __________________.
Bad White [126]

In a car crash, wearing a seat belt

A. Keeps you from being thrown from the car

B. can reduce injuries

The answer is : C. all of the above

<h3>Further explanation </h3>

In Newton's law, it is stated that if the resultant force acts on an object of magnitude is zero, it can be formulated:

<h3>∑F = 0 </h3>

This value is for stationary objects or objects that move in a straight line

So if the resultant force on an object is zero, the object that was initially stationary will continue to remain stationary, and the object that was initially moving will continue to move at a constant speed

The size of inertia is proportional to mass, the greater the mass of the object, the greater the inertia of the object.

In objects with mass that move translatively, the object will maintain its linear velocity

When we are in a vehicle that moves forward, then we will still maintain a state of forwarding motion. If our vehicle stops suddenly, then we keep moving forward so we will be pushed forward. From this point, the use of a safety belt serves to hold back our movements so that there are no fatal injuries or collisions.

<h3>Learn more </h3>

Newton's law of inertia

brainly.com/question/1412777

example of Newton's First Law of inertia

brainly.com/question/1090504

law of motion

brainly.com/question/75210

Keywords: inertia, Newton's First Law, collisions, injuries, car accident, crash

7 0
2 years ago
Read 2 more answers
Which of the statements below are true about Digital Signatures?
Leokris [45]

Answer:

The answer is "Option a, and c".

Explanation:

Following are the description of the Digital Signature choices:

  • To change the physical transportation of paper or link files in the computerized messaging system, some processes should be identified and utilized in digital signatures, which enables documentation to be validated unforgivably.
  • Using public-key cryptography, digital signatures, that's an exquisite system, that's why options a and b are correct.
  • Digital signatures are not a central authority, that's why the option B is wrong.
5 0
3 years ago
1.where should the name of the website or company logo appear on a website
Paul [167]

Answer:

1. First Page

2. Two Colors

8 0
3 years ago
Read 2 more answers
A _________ is a series of commands and instructions that you group together as a single command to accomplish a task automatica
melamori03 [73]
A macro is a series of commands and instructions that you group together as a single command to accomplish a task automatically.
8 0
3 years ago
Can someone help me with this
Alex787 [66]
I’m not sure but I think it belongings.
5 0
2 years ago
Other questions:
  • 1. Jesse wants a recommendation about creating an SCR help desk. She said that I can find lots of information about help desks o
    7·1 answer
  • What CLI command can be issued in CentOS 7 to help you to see every "hop" that a connection makes, including all of the switches
    13·1 answer
  • Which key on a laptop keyboard is often used to help pair a mobile device with another device for communication purposes?
    12·1 answer
  • Unix has experimented with several security programs. a user can attach a watchdog program to a file that grants or denies acces
    13·1 answer
  • Jeff needs to apply a theme and change the font of the theme in the presentation that he is making. Put the steps in the order t
    14·1 answer
  • Can you clone apps form your PC and to other PC?<br>Yes or No
    13·2 answers
  • Develop a Python program. Define a class in Python and use it to create an object and display its components. Define a Student c
    11·1 answer
  • Proxy download for school
    15·2 answers
  • Look at (c), is it accurate? ​
    9·2 answers
  • What is referential integrity
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!