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 type of exception would be detected if you used the conversion command Convert.ToDecimal to try to convert an ampersand?
Anestetic [448]

Answer:

Visual basic

Explanation:

Implicit and Explicit Conversion

4 0
3 years ago
What could cause this? An App Builder wants to show Groups as the last navigation menu item in the Salesforce1 Mobile App. Howev
sasho [114]

Answer:

Option B is the correct option.

Explanation:

In the above scenario, When they wanted to demonstrate Groups as the last menu item for navigation in the Mobile App. Then, they can't select Groups as among the elements in the drop-down menu though.

So, the following scenario causes that the Groups are not contained in the selected list for the navigation menu.

4 0
3 years ago
In computer science, what does it mean to interface?
Sati [7]

D, To communicate with a computer through a device or program :)

3 0
2 years ago
What is meant by slide rule?​
OleMash [197]

Answer:

a manual device used for calculation that consists in its simple form of a ruler and a movable middle piece which are graduated with similar logarithmic scales.

Explanation:

^

5 0
2 years ago
on which two interfaces or ports can security be improved by configuring executive timeouts? (choose two.)
ELEN [110]

Executive timeouts are configured using ports such as Console port, Aux port, VTY port.

Executive time outs are used to automatically disconnect devices which have been idle for a specific period of time.

In IOS devices, the executive timeout automatically disconnect users after 10 minutes of inactivity. These users can either be console or VTY user. The executive timeout can be set using line mode command.

Executive timeouts are configured using ports such as Console port, Aux port, VTY port.

Find out more using: brainly.com/question/13025617

5 0
2 years ago
Other questions:
  • Which activity represents a violation of the licensing agreement
    7·2 answers
  • What can be determined from this selection? Check all that apply. The Tax Info worksheet is currently being viewed. There are th
    6·2 answers
  • When using _____, developers are required to comply with the rules defined in a framework. (Points : 2) inheritance
    12·1 answer
  • How to write a function that counts the letters in a string in C?
    13·1 answer
  • I have to write this in Java, but i've never even learned it before and i'm completely lost
    12·1 answer
  • During his last performance review, Franco's boss urged him to set some short-term and long-term sales goals to help him perform
    6·2 answers
  • What are the characteristics of the sorting and grouping options in Outlook? Check all that apply. Columns can be sorted by clic
    15·2 answers
  • 1:A presentation program which is developed by Microsoft
    12·2 answers
  • What is the function of a primary key in a table? to uniquely identify each record in the table to uniquely identify foreign key
    9·1 answer
  • B. WAP to check whether input number is palindrome number or not using SUB...... END SUB.​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!