Question
Please help me with this C++ project. Thanks Using C++ with string fucntion and C-string (strlen, strcat, etc..) to write a program that will prompt
Please help me with this C++ project. Thanks
Using C++ with string fucntion and C-string (strlen, strcat, etc..) to 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 persons last name comma, nickname (in all caps, enclosed in double quotes) and first name.
- Then output the modified string.
Ex: Doe, ROWDY John
- Then Output first and last name alternating each character: John Doe Ex: JDoohen Tim Wheaterton Ex: TWihmeaterton
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)?
- Here is my code so far:
int main(String[] args) {
Scanner input = new Scanner(System.in);
String name, nickname, first, last;
char choice;
do
{
System.out.println("Please enter your first and last name: ");
name = input.nextLine();
System.out.println("Your name is : " + name);
System.out.println("Please enter your nickname");
nickname = input.nextLine();
nickname = nickname.toUpperCase();
...
System.out.println("Do you wish to enter another name(y/n)?");
choice = input.next().toLowerCase().charAt(0);
input.nextLine();
} while (choice != 'n');
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started