So, I for this assignment I need the user to put their first and last name on one line, then their nickname on its own line, and this display is as Firstname "Nickname" Lastname. I've been fighting with it and currently have one problem after another. I don't know how to do this, but have most of the program laid out. Any ideas?
Here's the actual Assignment:
Using string functions and all other programming features discussed in
the class, write a program that will prompt a user to input their name
(first and last).
Ex: Please enter your first and last name: John Doe
Then, output the string.
Next, prompt the user to input their nickname.
Ex: Enter your nickname: Rowdy
Then modify the name string to consist of the person’s first name,
nickname (in all caps, enclosed in double quotes) and last name.
Then output the modified string.
Ex: John “ROWDY” Doe
NOTE: This program should loop, prompting the user to decide
whether or not he or she wishes to enter another name.
Ex: Do you wish to enter another name(y/n)?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
#include <iostream>
#include<fstream>
#include<iomanip>
#include <string>
#include <cctype>
using namespace std;
const int SIZE = 25;
struct name_components
{
string fullname;
string firstname;
string lastname;
string nickname;
};
name_components name;
bool c = "y";
int main()
{
while (c = "y")
{
cout << "Enter Your First and Last Name Please: " << endl;
cin >> name.fullname;
cout << "Enter You Nickname Please: " << endl;
cin >> name.nickname;
cout << "Do You Wish to Enter Another Name(y/n)?" << endl;
cin >> c;
return 0;
}
c = "n";
}
|