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
"the master boot record (mbr) method of partitioning hard drives is limited to what maximum size of drives
Vaselesa [24]
The answer is <span>2TB.  T</span>he master boot record (mbr) method of partitioning hard drives is limited to  2TB.  <span>The </span>Master Boot Record<span> (</span>MBR<span>) is the information in the first </span>sector<span> of any hard disk that identifies how and where an OS is located, so that it can be </span>boot<span> (loaded) into the computer's main storage or RAM.</span>
6 0
3 years ago
What when can you expect technology to be effective?
loris [4]

Answer:

we dont have to expect , the technology are effective , as each day the technology are being advance and developed day by day. each day the technology are being more and more effective. they are effective now and they will be effective in future too

3 0
2 years ago
On the Direct Marketing worksheet, create appropriate range names for Design Fee (cell B8), Cost Per Ad (cell B9), Total Clicks
Inessa [10]

Answer:

See explanation below

Explanation:

Named ranges are a very important tool in Microsoft Excel. It is used in assigning a name to a particular number of cells. It is great for automation and makes formula much easy to understand and use.

One way to create named ranges is theory the Name Box.

To create named ranges in the design marketing sheet we do this;

1) We click on cell B8 and then navigate to the name box at the top right corner of the sheet just above the column A.

•The name box is where the cell address of any cell that is active is displayed.

•You would see that “B8” is displayed on the name box.

• Double click on the name box and type in the appropriate name, in this case - Design_Fee.

• Press enter and you have your named range.

You do the same for the other named ranges.

Note that: Named ranges must contain letters, numbers or underscore.

4 0
3 years ago
What does an SQL injection do
Afina-wow [57]

Answer:

SQL injection is a form of hacking that uses user input fields.

Explanation:

SQL injection is when a piece of code or entire algorithm is input where a program prompts for user input. They can be used to change or access data. To prevent this, a programmer should scrub inputs. Scrubbing data removes slashes and arrows, which or commonly used in code.

3 0
2 years ago
Read 2 more answers
What was the first Apple computer, and who was it designed by?
DerKrebs [107]

Answer: The first Apple Computer was Apple 1. The designer was Steve Wozniak.

Explanation: Steve Wozniak and Steve Jobs both created Apple 1. Mainly, Steve Wozniak designed it.

Hope this helps!

7 0
3 years ago
Read 2 more answers
Other questions:
  • What type of function is the IF function?<br> Statistical<br> Logical<br> Financial <br> Text
    5·2 answers
  • In windows xp, which control panel icon should you choose if you would like to customize your system for left-handed use?
    7·2 answers
  • Jason is creating a web page for his school's basketball team. He just finished creating his storyboard. Which tool should he us
    6·2 answers
  • a paragraph is a segment of text with the same format that begins when you press the enter key and ends when you press enter key
    6·2 answers
  • If metal shims are used for alignment adjustment in the front, they adjust ________.
    5·1 answer
  • What is the quickest way to change the format of a table?
    8·1 answer
  • Rainfall_mi is a string that contains the average number of inches of rainfall in Michigan for every month (in inches) with ever
    12·1 answer
  • My computer just fried anybody know why it did that?
    14·2 answers
  • What would provide structured content that would indicate what the code is describing ?
    6·1 answer
  • What is a database and provide 2 examples of how you are using a database.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!