1 answer

C++ Strings Program

Question:

<p>Write a program that read's in a person's name in the following format: first name, then middle name or initial, and then last name. &#160;The programwill the output &#160;the name in the following format: <br />Last_Name, First_Name Middle_Initial.</p>
<p><br />For example, the input<br />Mary Average User<br />should produce the following output:<br />User, Mary A.<br />The input:<br />Mary A. User<br />should also produce the same output.</p>
<p><br />Your program should work the same and place a period after the middle initial even if the input did not contain a period.</p>
<p>&#160;Your program should allow for user who give no middle name or middle initial. &#160;In that case, the output, of course, contains no middle nameor middle initial. &#160;For example:<br />The input:<br />Mary User<br />should output:<br />User, Mary<br />Please use C++ -strings for this assignment, not C-Strings.</p>

Answers

#include <iostream>

#include <string>




using namespace std;




// ====================

// main function

// ====================

int main()

{

//

// Variable declarations

//

string first, second, third; // strings read in

char ch; // character in input after second string

char middleInitial;







//

// Get the first two strings read in (first and middle names or

// first and last names)

cout << endl;

cout << "Enter your name (first middle last): ";







// --------------------------------

// ----- ENTER YOUR CODE HERE -----

// --------------------------------







// --------------------------------

// --------- END USER CODE --------

// --------------------------------







return 0;

}.

Similar Solved Questions

1 answer
How do you solve #\frac{6}{8} = \frac{n}{3}#?
How do you solve #\frac{6}{8} = \frac{n}{3}#?...
1 answer
11-13 The z-component of a vector can be (+), (-), or zero A True B false...
11-13 The z-component of a vector can be (+), (-), or zero A True B false if A is perpendicular to B, then B middot A = 0 A True B False The x-component of a vector can be (+), (-), or zero A True B False The scalar (or dot) product of two vectors can be (+), (-) or zero A True B False If A = B tim...
1 answer
Required information (The following information applies to the questions displayed below.) Data for Hermann Corporation are...
Required information (The following information applies to the questions displayed below.) Data for Hermann Corporation are shown below: Selling price Variable expenses Contribution margin Percent Per Unit of Sales $ 90 1005 63 70 $ 27 30% Fixed expenses are $30,000 per month and the company is sell...
1 answer
Question 7 1 pts The hormone ADH stimulates water reabsorption at the ... The PCT and...
Question 7 1 pts The hormone ADH stimulates water reabsorption at the ... The PCT and DCT The DCT and collecting duct The descending limb of the Loop of Henle and collecting duct Collecting duct only Why do Type I Diabetes Mellitus patients (DM) excrete lots of glucose in their urine (while non diab...
1 answer
Question 1 You are interested in studying the effect of the US minimum Rico. Therefore you...
Question 1 You are interested in studying the effect of the US minimum Rico. Therefore you use the following dataset wage on employment in Puerto Variable LPREPOP Log of the Puerto Rican employment per capita LMINCOVLog of the minimum wage relative to average wages Description time trend (1 to 38) L...
1 answer
Suppose you have two A-B-type exotoxins, A-B and A’-B’. A-B binds specifically to all MHC-II+ cells...
Suppose you have two A-B-type exotoxins, A-B and A’-B’. A-B binds specifically to all MHC-II+ cells and blocks vesicle trafficking. A’-B’ binds specifically to all MHC-I+ cells and stops protein synthesis. A. What would a hybrid toxin, A’-B, do to fibroblast (skin) cell...
1 answer
Verify the identity (3 sin 0+3 cos 0)2 = 9 + 9 sin 20 Begin by...
Verify the identity (3 sin 0+3 cos 0)2 = 9 + 9 sin 20 Begin by working with the left side Square (3 sin 0+3 cos 0). (Simplify your answer.)...
1 answer
Any athlete who fails the Enormous State University's women's soccer fitness test is automatically dropped from...
Any athlete who fails the Enormous State University's women's soccer fitness test is automatically dropped from the team. Last year, Mona Header failed the test, but claimed that this was due to the early hour. (The fitness test is traditionally given at 5 AM on a Sunday morning.) In fact, a...
1 answer
Just need help on 4 and 5 Proteins (For these questions, you may research online or...
just need help on 4 and 5 Proteins (For these questions, you may research online or from the prescribed text book to arrive at your answers), for each question, justify your answers through technical reasoning. (5 points each) I. What is the general structure of an α-amino acid? Give an overv...
1 answer
S-1+2+3+4+...+1000? S-1+3+9+27+81+...-? S-25/1.08+25/1.08 2+25/1.08A3+...+25/1.08 20-? S-1+4+8+16+32+64+...+2A100-? S-30/1.07 2+30/1.07A3+.. +30/1.07A40-? S-30/1.07 2+30/1.07A3+30/1.07A4+...-1? 142 1+k None of the...
S-1+2+3+4+...+1000? S-1+3+9+27+81+...-? S-25/1.08+25/1.08 2+25/1.08A3+...+25/1.08 20-? S-1+4+8+16+32+64+...+2A100-? S-30/1.07 2+30/1.07A3+.. +30/1.07A40-? S-30/1.07 2+30/1.07A3+30/1.07A4+...-1? 142 1+k None of the answers are correct 3t and kg TdE None of the answers are correct e-g...
1 answer
A soil was loaded with a regular footing (508 80) mm² whose reign IS 1280 KN....
A soil was loaded with a regular footing (508 80) mm² whose reign IS 1280 KN. Assume that the lowest normal stress is zero and the stress brought by the footing is the maximum normal stress. Determine the shear stress if. the soil is rotated 18° CON from its current plane....
1 answer
In each reaction box, place the best reagent and conditions from the list below. 1) Br2...
In each reaction box, place the best reagent and conditions from the list below. 1) Br2 2) 2 equiv. NaNH2 3) CH5CH2Br 4) Ha. Lindlar catalyst PBrs HЕг Вн-THF excess NANH2 CH Br H2O, H2SO4, HgSO4NaBH4 H202. NaOH, H20 Na, NH3 ()...
1 answer
Solve the IVP 61-6301(c) CO) -(0) +
Solve the IVP 61-6301(c) CO) -(0) +...
1 answer
P 4.38 12 of 18 > Review Consider the circuit shown in (Figure 1). Sketch i(t)...
P 4.38 12 of 18 > Review Consider the circuit shown in (Figure 1). Sketch i(t) to scale versus time. Plot the points for the values of t that are separated by the step Al = 0.28 No elements selected iz(t) (A) Figure 1 of 1 > -0 R = 10 + D + 02 04 06 08 10...
1 answer
Part C CH3 -CH2-CH=CH-CH3 + Br2 Draw the molecule on the canvas by choosing buttons from...
Part C CH3 -CH2-CH=CH-CH3 + Br2 Draw the molecule on the canvas by choosing buttons from the Tools (for bonds), Atoms, and Advanced Template toolbars. The single bond is active by default. c . . H: 1200 mA...
2 answers
What simple rigorous ways are there to incorporate infinitesimals into the number system and are they then useful for basic Calculus?
What simple rigorous ways are there to incorporate infinitesimals into the number system and are they then useful for basic Calculus?...
1 answer
Production costs chargeable to the Finishing Department in June in Hollins Company are materials $18,761, labor...
Production costs chargeable to the Finishing Department in June in Hollins Company are materials $18,761, labor $45,068, overhead $19,500. Equivalent units of production are materials 21,080 and conversion costs 19,990. Production records indicate that 18,900 units were transferred out, and 2,180 un...
1 answer
A sample 76 obese adults was put on a special low carbohydrate diet for a year....
A sample 76 obese adults was put on a special low carbohydrate diet for a year. The average weight loss was 11 lb and the standard deviation was 19 lb (note that, positive weight loss imply reduced weight over the time). a. Calculate the 99% confidence interval for the true mean reduction. b. Do you...