Question

(C++) There is a rumor circulating on the Internet that George Lucas (the creator of the...

(C++) There is a rumor circulating on the Internet that George Lucas (the creator of the Star Wars movies) uses a formula to create the names for the characters in his stories (Jar Jar Binks, ObiWan Kenobi, etc.) The formula allegedly-is the following:

Star Wars first name: • Take the first three letters of your last name. • Add to that the first two letters of your first name.

Star Wars last name: • Take the first two letters of your mother's maiden name. • Add to this the first three letters of the name of the town or city where you were born

Write a C++ program that lets the user enter their first and last name, first two letters of their mother’s maiden name, and the city/town of their birth. Output to the screen your Star Wars screen name (First and Last name). The program must include a function named GenerateStarWarsName() that generates a Star Wars name. The C++ String class must be used. Output should be user friendly.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code -


#include <iostream>
#include <cstring>
#include <string.h>

using namespace std;
void GenerateStarWarsName();
string firstName,lastName,maidenName,cityName;
int main()
{
//ask user to enter following details
cout<<"Enter of your first name: ";
cin>>firstName;
cout<<"Enter of your last name: ";
cin>>lastName;
cout<<"Enter of your mother's maiden name: ";
cin>>maidenName;
cout<<"Enter name of the town or city where you were born: ";
cin>>cityName;
//call function to generate star war name
GenerateStarWarsName();
return 0;
}
void GenerateStarWarsName() {
//this is take out the first two letters from first string
std::string firstNameTwoLetters = firstName.substr(0, 2);
//this is take out the last two letters from last string
std::string lastNameTwoLetters = lastName.substr(0, 3);
//use append method to concatenate string
lastNameTwoLetters.append(firstNameTwoLetters);
std::string maidenNameTwoLetters = maidenName.substr(0, 2);
std::string cityNameTwoLetters = cityName.substr(0, 3);
maidenNameTwoLetters.append(cityNameTwoLetters);
cout<<"\nStar war name : "<<lastNameTwoLetters<<" "<<maidenNameTwoLetters<<endl;

}

Screenshots -

Add a comment
Know the answer?
Add Answer to:
(C++) There is a rumor circulating on the Internet that George Lucas (the creator of the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • can someone help me with this program ? first name : Tom Last name : Damerji...

    can someone help me with this program ? first name : Tom Last name : Damerji Mother's maiden name : White Town i was born in : Beirut Write a new method that determines your Star Wars name. The method will have 4 parameters, your first name, last name, mothers maiden name, and the town you were born. (1 point) The method will return one String object, your Star Wars name.  (1 point) Your Star Wars name is created as per...

  • C++ developing involves ut from a file a person's first name, last name, phone number and...

    C++ developing involves ut from a file a person's first name, last name, phone number and birth a menu driven database application. You need to 4) This program accept as input ogram will be menu driven with the following options: 1) Find a person's information 2) Add a person to the database 3) Edit a person's information 4) Display all records to the screen 5) Quit Option 1 allows the user to enter a name after which you will search...

  • programming language is C++. Please also provide an explanation of how to create a file with...

    programming language is C++. Please also provide an explanation of how to create a file with the given information and how to use that file in the program Let's consider a file with the following student information: John Smith 99.0 Sarah Johnson 85.0 Jim Robinson 70.0 Mary Anderson 100.0 Michael Jackson 92.0 Each line in the file contains the first name, last name, and test score of a student. Write a program that prompts the user for the file name...

  • C Program In this assignment you'll write a program that encrypts the alphabetic letters in a...

    C Program In this assignment you'll write a program that encrypts the alphabetic letters in a file using the Vigenère cipher. Your program will take two command line parameters containing the names of the file storing the encryption key and the file to be encrypted. The program must generate output to the console (terminal) screen as specified below. Command Line Parameters Your program must compile and run from the command line. The program executable must be named “vigenere” (all lower...

  • C++ Lab 1. Read in the contents of a text file up to a maximum of...

    C++ Lab 1. Read in the contents of a text file up to a maximum of 1024 words – you create your own input. When reading the file contents, you can discard words that are single characters to avoid symbols, special characters, etc. 2. Sort the words read in ascending order in an array (you are not allowed to use Vectors) using the Selection Sort algorithm implemented in its own function. 3. Search any item input by user in your...

  • The ", delimiter" should now be changed to use the "^ delimiter". There needs to be...

    The ", delimiter" should now be changed to use the "^ delimiter". There needs to be an 2nd address field added to the original code, as well as, a "plus 4" on the zip code (example: 47408-6606). Then the additional prompts must be added. Thank you! Last Real-World problem (in module 04 - 05), you added functionality to allow the user to enter multiple patients until the user indicated done. You are to enhance this functionality. Add the following functionality...

  • Follow instructions to create a visual C++ project, add the CH code, compile, fun and fix...

    Follow instructions to create a visual C++ project, add the CH code, compile, fun and fix errors, Write your Name, course, and date as comments on first line. Write Program's Name epp (Give it your last name with the assignment number as a name... Program0 LAST NAME). Explain what the program is to do along with any directions or instructions needed for program users (ie the purpose of each library included next to #include directive, names and uses of identifiers...etc)....

  • COSC 1437 C++ Project Assignment 2 Poll Summary Utilize a dynamic array of structure to summarize...

    COSC 1437 C++ Project Assignment 2 Poll Summary Utilize a dynamic array of structure to summarize votes for a local election Specification: Write a program that keeps track the votes that each candidate received in a local election. The program should output each candidate’s name, the number of votes received, and the percentage of the total votes received by the candidate. Your program should also output the winner of the election. To solve this problem, you will use one dynamic...

  • Java I: Create a Java program that will accept the price of an item and the...

    Java I: Create a Java program that will accept the price of an item and the quantity being purchased of that item. After accepting the input, calculate the amount of the purchase (based on the price and quantity), calculate the sales tax on the purchase, then output the product price, quantity, subtotal, sales tax, and the total sale based on the output format shown below. Structure your file name and class name on the following pattern: The first three letters...

  • This assignment tests your ability to write C programs that handle keyboard input, formatted console output,...

    This assignment tests your ability to write C programs that handle keyboard input, formatted console output, and input/output with text files. The program also requires that you use ctype functions to deal with the logic. In this program, you will input from the user two characters, which should both be letters where the second letter > the first letter. You will then input a file character-by-character and output those letters that fall between the two characters (inclusively) to an output...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT