1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
serg [7]
3 years ago
9

Write a program whose input is an email address, and whose output is the username on one line and the domain on the second. Exam

ple: if the input is:
[email protected]

Then the output is

username: pooja

domain: piazza.com

The main program is written for you, and cannot be modified. Your job is to write the function parseEmailAddress defined in "util.cpp" The function is called by main() and passed an email address, and parses the email address to obtain the username and domain. These two values are returned via reference parameters. Hint: use the string functions .find() and .substr(),

main.cpp is a read only file

#include
#include

using namespace std;

// function declaration:
void parseEmailAddress(string email, string& username, string& domain);

int main()
{
string email, username, domain;

cout << "Please enter a valid email address> ";
cin >> email;
cout << endl;

parseEmailAddress(email, username, domain);

cout << "username: " << username << endl;
cout << "domain: " << domain << endl;

return 0;
}

/*util.cpp*/ is the TODO file

#include
#include

using namespace std;

//
// parseEmailAddress:
//
// parses email address into usernam and domain, which are
// returned via reference paramters.
//
void parseEmailAddress(string email, string& username, string& domain)
{
//
// TODO: use .find() and .substr()
//

username = "";
domain = "";

return;
}
Computers and Technology
1 answer:
kirill115 [55]3 years ago
6 0

Answer:

1 void parseEmailAddress(string email, string& username, string& domain)

2 {

3   int found = email.find("@")

4   if (found > 0)

5   {  

6     username = email.substr(0, found);  

7      domain = email.substr(found+1, -1);

8   }

9   return;

10}

Explanation line by line:

  1. We define our function.
  2. We use an open curly bracket to tell the program that we are starting to write the function down.
  3. We apply the find method to the email variable that was passed by the main program. The find method tells us where is the "@" located within the email.
  4. We use an if statement to ensure that the value that we found is positive (The value is negative if an only if "@" is not in the email address).
  5. We use an open curly bracket to tell the program that we are starting to write inside the if statement.
  6. We apply the substr method to the email to take the username; it receives a start and an end value, this allows us to take from the beginning of the email (position 0) until the "@".  
  7. We apply the substr method to the email to take the domain; it receives the position of the "@" character plus one to take the first letter after the "@" and a minus-one representing the last character on the email.
  8. We use a closing curly bracket to tell the program that the if statement has finished.
  9. We return nothing because we are using reference parameters, which means that the memory positions of username and domain are going to be filled by our parseEmailAddress function and the main function can access those values directly.
  10. We use a closing curly bracket to tell the program that the function has finished.
You might be interested in
I got a 52 on my test :(
Eduardwww [97]

Answer:

that sucks i hope u can do better next time have a good day

Explanation:

7 0
3 years ago
**PLEASE AN IPO CHART AND A C++ PROGRAM FOR EACH QUESTION**
Yuki888 [10]

answer is b

rtyujhygtrcdxrtgyhgtfr

7 0
2 years ago
​Five elements that can prove the genuineness of a user: what you know, what you have, what you are, what you do, and where you
yuradex [85]

Answer: Authentication factor

Explanation: Authentication factor are the factors that describes about the ingenuity or originality of the user .This is the term that tells about the actuality of user that is getting connected with network by the five elemental question .

The question is regarding the possession, inherency, knowledge/information , identity and location.The answers to these question help in finding the authenticated user.

6 0
3 years ago
Read 2 more answers
Have you seen this ProFlipperz Review? It is a course on how to flip every day household items for a profit.
Nadusha1986 [10]

Well if you have one I know it's cool but don't flip it all the time

Explanation:

6 0
2 years ago
E) ¿Entiende usted que tendría repercusión legal un mal manejo de los datos del cliente por parte de la empresa? ¿Por qué?
weqwewe [10]

Answer:

Efectivamente, un mal manejo de los datos del cliente por parte de la empresa tendría repercusiones legales que afectarían negativamente a la compañía. Esto es así porque un eventual mal manejo de los datos personales de los clientes implicaría una filtración de dichos datos hacia el resto del público, con lo cual los datos personales y privados de cada cliente se verían expuestos en forma pública, generando así posibles daños a estos a través de la mala utilización de dicha información por parte de terceros malintencionados.

4 0
2 years ago
Other questions:
  • The information security organization performs a significant role in the implementation of solutions that mitigate risk and cont
    6·1 answer
  • The _____ is the area in Microsoft Excel where you can perform file commands such as Save, Open, and Print
    15·1 answer
  • Which of the following sentences uses the correct verb tense?
    8·2 answers
  • Which of the following should be considered when conducting an audience analysis ?
    13·2 answers
  • Write a Python program calculate summary statistics about a class assignment. First, prompt the user for the number scores to be
    6·1 answer
  • Write HTML code for inserting an image "cricket.jpeg" in size 500 width and 400 height.
    12·1 answer
  • SNMP is a protocol used to query hosts, servers, and devices about performance or health status data. This protocol has long bee
    7·1 answer
  • Write a couple of paragraphs about the usefulness of computer​
    5·1 answer
  • Choose the correct definition for Conditional Statement A. Affects the sequential flow of control by executing different stateme
    6·2 answers
  • PLEASE HELP ME!!!
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!