Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Parallel Arrays

    • 0
    • 0
    • 0
    • 2
    • 0
    • 0
    • 0
    • 1.90k
    Answer it

    Create a program that allows the user to input a list of first names into one array and last names into a parallel array. Input should be terminated when the user enters a sentinel character. The output should be a list of email addresses where the address is of the following form:  first.last@stallion.edu

    What does the question mean in the bolded statement, is the user to input a full name which is then coded in a first and last name array and if so, how would I do that or I am to just create a normal array for first name as in: First_Name[J] = " " {J would be the counter to move from element to element as in J initialized to 0 then J++ and so on...} and another for last name or just create two parallel arrays for last names as in: Last.Name[J] = " " Last1_Name[J] = " " and input both for when the user enter a last name.

    Apologies if this sounds convoluted but I am as confused as you right now. My class is not that great and my professor I believe is on 'vacation'

    Confused
    /nana

 2 Answer(s)

  • Hi, I suggest you to do it using vector but if you want to use array then please have a look on the below approach.

    #include <iostream>
    #define LIMIT 100
    

     
    using namespace std; int main() { string first_name[LIMIT]; string last_name[LIMIT]; string str1; string str2; int j = 0; char sentinelCharater = 'n'; char sentinelInput; cout << "Enter 'y' to continue else 'n' to stop taking inputs : "; cin >> sentinelInput; while(sentinelInput != sentinelCharater) { cin >> str1 >> str2; first_name[j] = str1; last_name[j] = str2; j++; cout << "Enter 'y' to continue else 'n' to stop taking inputs : "; cin >> sentinelInput; } cout << "\n\nResults" << endl; for (int i = 0; i < j; i++) cout << first_name[i] << "." << last_name[i] << "@" << "stallion.edu" << endl; return 0; }

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: