Answer to Question #325106 in C++ for nickname

Question #325106

Create a program that asks the user to enter the names of their last three employers. Output the names entered to confirm. Ask the user if the confirmation output is correct. If Yes, end the program. If No, then ask for the three names again.

 

Output:

This program will ask you to enter the company name of your last three employers.

Enter the company name:   [user types: 123 Corp]

Enter the company name:   [user types: 789 Corp]

Enter the company name:   [user types: Kendall Corp]

These are the company names you entered:

123 Corp

789 Corp

Kendall Corp

Are these three names correct (Y or N)?  [user types: n]

Enter the company name:   [user types: ABC Corp]

Enter the company name:   [user types: XYZ Corp]

Enter the company name:   [user types: Miami Corp]

These are the company names you entered:

ABC Corp

XYZ Corp

Miami Corp

Are these three names correct (Y or N)?  [user types: y]



1
Expert's answer
2022-04-12T13:28:20-0400
#include<iostream>
#include<string>

using namespace std;

int main()
{
	string Employers[3];
	char choice;
	do
	{
		for (int i = 0; i < 3; i++)
		{
			cout << "Enter the company name:";
			getline(cin, Employers[i]);
		}
		for (int i = 0; i < 3; i++)
		{
			cout <<Employers[i]<<endl;
		}
		cout << "\nAre these three names correct (Y or N)?";
		cin >> choice;
		cin.ignore(256,'\n');
	} while (choice != 'Y');
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS