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]
#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');
}
Comments
Leave a comment