Purchase Solution

C++ Program to Read a Person's Names

Not what you're looking for?

Ask Custom Question

Write a program that reads a person's name in the following format: first name, then middle name or initial, and then last name. The program then outputs the name in the following format:

Last_Name, First_Name Middle_Initial.

For example, the input
Mary Average User

should produce the output:
User, Mary A.

The input
Mary A. User

should also produce the output:
User, Mary A.

Your program should work the same and place a period after the middle initial even if the input did not contain a period. Your program should allow for users who give no middle name or middle initial. In that case, the output, of course, contains no middle name or initial. For example, the input
Mary User

should produce the output
User, Mary

If you are using C strings, assume that each name is at most 20 characters long. Alternatively, use the class string. Hint: You may want to use three string variables rather than one large string variable for the input. You may find it easier to not use getline.

Purchase this Solution

Solution Summary

A C++ program is written to read a person's name in the following format: first name, then middle name or initial, and then last name. The program then outputs the name in the following format: Last_Name, First_Name Middle_Initial.

Purchase this Solution


Free BrainMass Quizzes
Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

C++ Operators

This quiz tests a student's knowledge about C++ operators.

Basic Networking Questions

This quiz consists of some basic networking questions.