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

  Repeat these questions by writing functions

Repeat these questions by writing functions that receive the arrays as constant reference parameters and return the appropriate values through the function name (via return statement). The function header could look like:

  Calculates the average of numbers

Write a C program which takes n number of element from user (where, n is specified by user), stores data in an array and calculates the average of those numbers. Output of the program should look like this;

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write a recursive method fibonacci that returns

Write a recursive method Fibonacci that returns the nth Fibonacci number when passed the argument n and Write a non-recursive version of the method Fibonacci.

  Write an algorithm that converts a decimal number

Write an algorithm that converts a decimal number between 0 and 15 into its 4 bit unsigned binary representation and write an algorithm that converts a linear measurement in feet and inches into meters. One inch is equivalent to 2.54 centimeters.

  The program will read integers values

Write a C++ program to do the following. The program will read integers values one at a time from standard input (cin) until you read the value 150. assume that the number of values read in is at least 1 and less than or equal to 100

  Shows the effect of the preceding statements

The following program shows the effect of the preceding statements.

  Matching program that takes input from a text file

need to make a string matching program that takes input from a text file and outputs that match (if there is one) asked from the user. i have done this part , the only problem is that , with the output match , i also need to print some words before a..

  Takes 100 number in an array

Write a program in c++ that takes 100 number in an array and add them and print the sum

  Prints the row sums and the column sums

Write a program that reads a 5 x 5 array of integers and then prints the row sums and the column sums

  Create a class called point3d

Create a class called Point3D to represent 3D point in space, a class called Sphere and a class called Cylinder. The sphere is characterized by its center point and the radius while the Cylinder can be characterized by its center point, radius and he..

  Write a program that will find the smallest number

How to do the subsequent program WITHOUT USING Arrays - Write a program that will find the smallest, largest, and average values in a collection of N numbers. Get the value N before scanning each value in the collection of N numbers.

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