CHALLENGE ACTIVITY 2.15.1: Reading and outputting strings. Write a program that reads a person's first and last names, separated by a space. Then the program outputs last name, comma, first name. End with newline. Example output if the input is: Maya Jones Jones, Maya 1 2 3 4 5 6 7 8 9 10 11 12 #include #include using namespace std; int main() { string firstName; string lastName; /* Your solution goes here */ return 0; } 1 test passed All tests passed Run

Respuesta :

ijeggs

Answer:

#include <iostream>

using namespace std;

int main()

{

   string Fname, Lname;

   cout << "Please Enter your first name " <<"Please Enter Your Last Name" <<endl;

   cin>>Fname>>Lname;

   cout<<Lname<<", "<<Fname<<endl;

   return 0;

}

Explanation:

This program is written in C++ programming Language. Firstly two string variables are declared these are Fname and Lname for first and last name respectively. C++ cout statement is used to prompt user for inputs and the cin statement is used to save the inputs in the respective variables. Using the cout operators (<<) the output is formatted as required by the question

Answer:

import java.util.Scanner;

public class SpaceReplace {

  public static void main(String[] args) {

     Scanner scnr = new Scanner(System.in);

     String firstName;

     String lastName;

     firstName = scnr.next();

     lastName = scnr.next();

     

     System.out.println (lastName + ", " + firstName);

  }

}

Explanation:

its kinda self explanatory