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
iogann1982 [59]
2 years ago
15

For this programming assignment, you have to write a Java program that tests whether a given input string represents a Valid E-m

ail address. If the input is not a valid e-mail address, it should print a message saying "Invalid Address". If the input is a valid e-mail address, it should print out the User name and the Domain name on separate lines. For purposes of this assignment and to keep the logic simple, a valid E-mail address will be of the form
Computers and Technology
1 answer:
Step2247 [10]2 years ago
8 0

Answer:

To check if the email address is correct it should have only one "@" symbol, we have to split the input string by this symbol. The code in java to achieve this is the following:

class Main {

 public static void main(String[] args) {

   String email = "[email protected]";

   String[] email_split = email.split("@");

   long count_a = email.chars().filter(ch -> ch == '@').count();

   if(count_a == 1){

     System.out.println("User name:   "+email_split[0]);

     System.out.println("Domain name: "+email_split[1]);

   }else{

     System.out.println("There is no valid email address.");

   }

 }

}

Explanation:

The explanation of the code is given below:

class Main {

 public static void main(String[] args) {

   String email = "[email protected]"; //input string to evaluate if is valid email

   long count_a = email.chars().filter(ch -> ch == '@').count(); //Count how many times the symbol @ appears

   if(count_a == 1){ //A valid email only contains one at

     String[] email_split = email.split("@"); //separate the values using the at in an array

     System.out.println("User name:   "+email_split[0]); //the first element is the username

     System.out.println("Domain name: "+email_split[1]); //the second element is the domain name

   }else{

     System.out.println("There is no valid email address."); //If there isn´t an at or are more than one then display a message saying the email is not valid

   }

 }

}

You might be interested in
The only requirement of __________ is that the sender must provide some mechanism whereby the receiver can opt out of future ema
fiasKO [112]

Answer:

The CAN-SPAM Act

Explanation:

Email or electronic mail is an information system mechanism of communication, that involves the use of digital devices to initiate communication over the internet. The email uses several protocols like the POP3, IMAP etc.

The CAN-SPAM Act is proposed in the United States law, applicable to email investigations. It requires that a sender provides a mechanism whereby the receiver can opt out of future emails without a fee.

4 0
2 years ago
Define lan wan & man
Anuta_ua [19.1K]
A LAN (local area network) is a group of computers and network devices connected together, usually within the same building. By definition, the connections must be high speed and relatively inexpensive (e.g., token ringor Ethernet). Most Indiana University Bloomington departments are on LANs.

A LAN connection is a high-speed connection to a LAN. On the IUB campus, most connections are either Ethernet (10 Mbps) or Fast Ethernet (100 Mbps), and a few locations have Gigabit Ethernet (1000 Mbps) connections.

A MAN (metropolitan area network) is a larger network that usually spans several buildings in the same city or town. The IUB network is an example of a MAN.

A WAN (wide area network), in comparison to a MAN, is not restricted to a geographical location, although it might be confined within the bounds of a state or country. A WAN connects several LANs, and may be limited to an enterprise (a corporation or an organization) or accessible to the public. The technology is high speed and relatively expensive. The Internet is an example of a worldwide public WAN.

3 0
3 years ago
How do you implement instruction level parallelism
netineya [11]

Answer:

To obtain substantial performance enhancements, we must exploit ILP across multiple basic blocks.

Explanation:

8 0
2 years ago
If you have a database with birthdates, and you would like to find everyone who was born before June 16, 1967, what would you en
Tcecarenko [31]

Answer:

<June 16,1967

Explanation:

7 0
3 years ago
Read 2 more answers
When writing potential test questions, it is very important to use vocabulary words in their correct form. Please select the bes
Ilya [14]
The answer is True.

Hope I helped!
6 0
3 years ago
Read 2 more answers
Other questions:
  • When approved for a loan, an individual essentially applied for aid in the area of...
    15·1 answer
  • User accounts will be locked out after authentication is attempted
    7·1 answer
  • 1.) How do parks and other green spaces benefit a community?
    7·2 answers
  • 3. What is the purpose of the conclusion in an expository essay? (1 point)
    8·2 answers
  • But this time use 16 kib pages instead of 4 kib pages. what would be some of the advantages of having a larger page size? what a
    11·1 answer
  • A variation of pronounce is a. Proclaim c. Produce b. Profound d. Pronunciation Please select the best answer from the choices p
    11·1 answer
  • Which of the following is not a type of Internet Job Board? Options Resume Blaster Professional Association Target Applicants We
    8·1 answer
  • Which are the 2 main elements that’s make up computer architecture?
    6·2 answers
  • If C2=20 and D2=10 what is the result of the function = mathcal I F(C2=D2,^ prime prime Ful "Open")?
    11·1 answer
  • a) consider the binary number 11010010. what is the base-4 representation of (11010010)2? (there is a way to do this without con
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!