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
Which lighting technique can often heighten a dramatic story?
Elina [12.6K]

Answer:

side or back lighting

Explanation:

big brain

6 0
3 years ago
Jim, your organizations IAM, has been contacted by the Program Manager to assist in implementing the DIACAP. Jim is not required
padilas [110]

IAM stands for<em> </em>Identity Access Management and includes processes focused on control of user access to critical information.

DIACEP on the other hand stands for DoD Information Assurance Certification and Accreditation Process and it is a process which ensures that companies  apply risk management to information systems (IS). According these explanations, the statement that Jim who is IAM in the organization is not required to assist the PM in implementing the DIACAP is false. In contrast, it is required that he works on this process.

5 0
3 years ago
Which type of message format is designed to arouse curiosity, not showing the product or delivering quite enough information to
Anarel [89]

The type of message format that is designed to arouse curiosity by not showing the product or delivering quiet enough information to make sense is teaser. This is a way of providing information that is short and in which it does not identify the product or the whole message itself. 

7 0
3 years ago
In order for a fault-block mountain to form, a ______ must take place along a fault line and one side must be ________.
Sav [38]
I think the correct answer from the choices listed above is the first option. In order for a fault-block mountain to form, a shift must take place along a fault line and one side must be elevated. Fault-block mountains form<span> when Earth's crust pushes material up and down near a </span>fault line<span>. Hope this answers the question.</span>
7 0
3 years ago
Imagine the user types in a complete sentence, but we want to read only the first word and place it in the String variable word.
Vladimir [108]

Answer:

import java.util.Scanner;

public class FirstWord {

   public static void main(String[] args) {

       //NOW YOU WANT TO COLLECT INPUTS FROM THE STUDENT OR USER

       //IMPORT THE SCANNER CLASS FIRST  outside your class

       // THEN YOU CREATE AN OBJECT OF THE SCANNER CLASS

       Scanner input = new Scanner(System.in);

       

       //CREATE A VARIABLE TO HOLD THE USER INPUT

       String text = input.nextLine();

       

       //The variable holder will be used to store characters from the for loop

       String holder="";

       

       //Create a for loop that loops through the user's input

       for(int i=0; i<text.length(); i++){

           //As the loop increases, we get the character in the user's input and store them one by one in the variable holder

           holder+=text.charAt(i);

           if(text.charAt(i)==' '){

               //If the loop encounters a space, it means a complete word has been gotten from the user's input

               //Then the break below Breaks the loop, and the loop stops running

               break;

           }

       }

       System.out.println(holder);

}

Explanation:

text.length() returns the length of the sequence of characters present in length

text.charAt(a number) Returns the char value at the specified index. An index ranges from 0 to length() - 1. The first char value of the sequence is at index 0, the next at index 1, and so on, as for array indexing.

Create a for loop

How does a for loop work?

It collects a starting point, an end point and an increment respectively....all these are passed in as arguments into the for loop

For example, the code above starts from 0, calculates the number of characters in the user's input and sets it as the end point, the loop runs from zero to the length of the text of the user...

Note: i++ in the loop is the increment, it means the loop increases by 1

8 0
3 years ago
Other questions:
  • Leslie’s form collected a huge amount of data. Over time the employees felt that the applications slowed down. What should lesli
    12·1 answer
  • How does microchip work
    12·1 answer
  • Juliet is trying to increase her savings account and she decides that she is going save an additional $700 every month. If her m
    9·1 answer
  • - What are the different types of clients?
    12·1 answer
  • Explain how to utilize the computer in rooms management.​
    13·1 answer
  • Which phrase best describes a scenario in Excel 2016?
    5·2 answers
  • 01110101<br> +00100100<br> 00010001
    8·1 answer
  • Explain mechanical computer ,electromechanical and electronic computer with example<br>​
    11·1 answer
  • Some printers spray ink, while others use heat or lasers to create images.
    14·2 answers
  • Which properties would be useful to know to search for a Word document? Check all that apply.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!