Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

15.4: Emails Again Write a method with the following signature: public static boolean validEmail(String str) The method returns a boolean value for whether the email

15.4: Emails Again

Write a method with the following signature:

public static boolean validEmail(String str) 
  • The method returns a boolean value for whether the email is valid 
  • Hint: You've done this same thing on your previous assignment, just not with a method.
  • For this assignment we are going to "outsource" the work of determining whether an email contains an '@' to a method named validEmail.
  • Copy and paste the starter code inside the {} of a class named Email2. This method can be placed either above or below the main method:

public static boolean validEmail(String str) { //add the code for your method here }

  • Cut the for loop from main and paste it inside the {} of the method.
    • Note: Do not call the contains() method or you will get no credit for this assignment. You must use a for loop to detect the '@' symbol.
  • Verify that your new version of the program still works identically to Assignment 13.3

Welcome! Enter an email and I will tell you if it is valid. Please enter an email or q to quit: bob@jobs.com

That email address is valid.

Please enter an email or q to quit: bobajobs.com

That email address is invalid

Please enter an email or q to quit: bob@jobs

That email address is valid.

Please enter an email or q to quit: q

Goodbye!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

6. Explain the power of labels.

Answered: 1 week ago

Question

10. Discuss the complexities of language policies.

Answered: 1 week ago