Write a program that request a students name

Assignment Help C/C++ Programming
Reference no: EM13703791

Program: Write a program that request a student's name in the subsequent form: lastName,firstName.

The program then converts each name to the following form: firstName lastName. Your program must read the student's entire name in a variable and must consist of a convertName function that takes as input a string, consists of a student's name, and returns the string consisting of the altered name.

Use the string function find to find the index of a ","; the function length to find the length of the string; and the function substr to extract the firstName, and lastName

This is what I have so far... I am not sure if i am doing this right or how to use the ConvertName function...

using namespace std;

int main() {

    string firstName, lastName, fullName, chgName;

    string line;

    cout << "Enter your last name and first name separeted by a comma" ;

    cin >> fullName;

    cout <<" You entered: " << fullName << endl;

     int comma = line.find(',');

    int length = line.length();

    lastName = line.substr(0,comma);

    firstName = line.substr(comma+2, length);

 }

I cannot seem to get this to work for some reason could somebody give me a code to compare and test?

Reference no: EM13703791

Questions Cloud

Redesign the grading program as an object-oriented design : Redesign the grading program as an object-oriented design. We will start with a simple Student class. The student will have a name, an id (as a String) and a set of grades (as doubles).
What is the output of the statement : Given the subsequent array declaration, if the array is stored starting at address 2500, what is the output of the following statement?
Can firm increase variability of its product line : Can a firm increase the variability and diversity of its product line while simultaneous realizing the higher possible level of efficiency? Provide one product example for illustration.
Babylonian algorithm : Babylonian Algorithm. The Babylonian algorithm to compute the square root of a positive number n is as given:
Write a program that request a students name : Write a program that request a student's name in the subsequent form: lastName,firstName.
Determining the volume of the unit sphere : Write a C program for determining the volume of the unit sphere by the Monte Carlo Method      \(x^{2}+ y^{2} + z^{2} 0, y > 0, z > 0.\)    : This is what I have so far, but it's not working.
How will cyber security influence the next 10 years : How will cyber security influence the next 10 years?
Prepare a main function : Write a function that converts an input of some integer number of nickels into outputs of integer numbers of dollars, quarters, and nickels.
Canonical product of sums : Design a majority circuit. This is a circuit which produces a 1 anytime there are more 1's than 0's on the inputs. Your circuit should have 3 inputs.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create a class to hold credit card information

The information to store is the card type (Visa, Mastercard, etc.) card number, the limit, and the current balance.

  Create an array of customer names

In preparation for more complex data processing tasks using object-oriented objects that you will create in up-coming units, in this unit you will utilize arrays to build some basic processing logic and structures.

  Write a c++ program that creates and populate a tree

Write a C++ program that creates and populate a tree for an arithmetic expression. Then it should perform an in-order and a post-order traversal on the tree.

  Create a program that counts the number of numbers

you need to create a program that counts the number of numbers between 150 and 200 - Can you write this program in c language? You need to implement a function that counts the numbers.

  Value of x after the following code is executed

What will be the value of x after the following code is executed?int x = 20, y = 30;while (y

  Write a program that will represent an axis-aligned

Write a program that will represent an axis-aligned right triangle in the x-y plane as a Class. A right triangle has a right angle (90-degree angle) and two sides adjacent to the right angle, called legs. See http://en.wikipedia.org/wiki/Right_tri..

  Prompts the user to enter time in 12-hour notation

Write a program that prompts the user to enter time in 12-hour notation. The program then outputs the time in 24-hour notation. Your program must  contain  three  exception  classes

  Write a loop that read positive integers from standard input

Any value that is the same as the immediately preceding value is considered a CONSECUTIVE DUPLICATE. In this example, there are three such consecutive duplicates: the 2nd and 3rd 5s and the second 6. Note that the last 3 is not a consecutive dupli..

  Prints out a multiplication table up to a specification

Create a program using C++ that prints out a multiplcation table up to a specfic limit. The code should prompt the user for the limit and then print out the table.

  Write a program that will read in 4 test scores per line

Write a program that will read in 4 test scores per line. Print the total number of points earned, your program should work for any number of lines of data.

  Write a function that permanently swaps two integers

Write a function that permanently swaps two integers using pointers.

  Using an appropriatenbspcnbspsyntax write the code required

using an appropriatenbspcnbspsyntax write the code required to analyse and display the data as per the problem

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd