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]
3 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]3 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
Which of the following statements best describes the relative amount of content held by digital libraries vs. the amount held by
Lesechka [4]

Answer:

Digital libraries tend to have access to more information because they can share with other digital libraries.

Explanation:

A digital library can be defined as an electronic or cloud-based library where informations and books about various things, places, people, animals, subjects, etc, are kept for readers to access over the internet.

On the other hand, a traditional library is a physical library that people can walk into to read.

The statement which best describes the relative amount of content held by digital libraries vs. the amount held by traditional libraries is that, digital libraries tend to have access to more information because they can share with other digital libraries because they are usually interconnected through network.

5 0
3 years ago
Create a class called Home that contains 4 pieces of information as instance variables: county (datatype string), street (dataty
DerKrebs [107]

Answer:

class Home // create class Home

{

// instance variable declaration

string county; // variable county of string datatype

string street; // variable street of string datatype

int housenumber; // variable housenumber of int datatype

string state; // variable state of string datatype

}

Explanation:

Here we declared a class 'Home ' which consist of 4 instance variable.

The instance variable are declared inside the class.We declared  variable county,street,state as string type and housenumber as integer type.

6 0
3 years ago
Which pair of Information Technology career fields may require work to be done outside of normal office hours? interactive media
scZoUnD [109]

Answer:

The answer to this question is "information services and support and network system administration".

Explanation:

The information support and service and network system administration is used to outside work, which can be explained as follows:  

  • The information support and service process is using information processing that is defined as the system for record-keeping, forms, figures and data in a business.  
  • A network or device system administrators are responsible for the day-to-day deployment of all these networks. They arrange, restore, and promote the computer systems of the company, which include local area networks, WANs, system sections, web services, and other wireless communication systems. The system provides local area networks.

6 0
3 years ago
Read 2 more answers
According to the information presented in this​ video, a spreadsheet is effective for managing information about one thing​ (e.g
Nat2105 [25]

Answer:

According to the information presented in this​ video, a spreadsheet is effective for managing information about one thing​ (e.g., items for​ sale), but a

C. database

is better for managing information about more than one thing​ (e.g., items for sale and suppliers of​ items).

Explanation:

  • The option A is not correct as the flowchart is a step-by-step explanation of a procedure. It is visual presentation in which we explain a whole process.
  • The  option B is not correct as network is defined as the group of different computers, servers and other machines that helps the exchange of data.
  • The option c is correct as database is the means of storage of data as well as we can access this data at any time and it let you manage the data as well so we can manage a lot of information about multiple things at a time.
  • The option d is also incorrect as workflow is the visual presentation of sequence in which tasks are performed so it doesn't have to do anything wit the managing the information.
  • The option e is also incorrect as data model defines the properties of data of different things and it is used in database. It sets the rule of storing, managing and accessing the data in a database.
7 0
3 years ago
What number system is the basis for all of the powerful computers and electronic devices in the world?
labwork [276]

Answer:

Binary

Explanation:

3 0
3 years ago
Other questions:
  • Mile markers appear as _____ green signs.
    6·2 answers
  • How to Ctrl + shift + F4 but in a HP laptop?​
    8·2 answers
  • Is a small file that a web server writes to the disk drive of the client computer, containing information about the user?
    8·1 answer
  • Under the class system, how many host ids were available in a class b network?
    7·1 answer
  • Can someone please‼️‼️❗️help me with this?<br> I got an error that I can’t figure out how to fix it.
    6·1 answer
  • Why would a network administrator want to filter certain ports when capturing data such as FTP traffic
    6·1 answer
  • What is the output of the following code<br> X = 06<br> y = 0<br> print (x ** y)
    12·1 answer
  • Suppose that a NAT is between the Internet and a company's network. Now suppose that the NAT crashes, but quickly restarts, in a
    7·1 answer
  • Es costoso construir un robot
    6·1 answer
  • Which of the following HTML codes is correct for an ordered list?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!