answer.
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
jarptica
11 days ago
5

Write a method, isEmailAddress, that is passed a String argument. It returns true or false depending on whether the argument has

the form of an email address. In this exercise, assume that an email address has one and only one "@" sign and no spaces, tabs or newline characters.
Computers and Technology
1 answer:
Amiraneli [921]11 days ago
8 0

Answer:

//This method takes a parameter called myString of type String

public static boolean isEmailAddress (String myString){

//verifying if the @ character exists in the string

if (myString.indexOf("@")!= -1) {

  //ensuring that only a single instance of @ appears in the string

   if (myString.indexOf("@") == myString.lastIndexOf("@")) {

   //confirming absence of space characters

  if (myString.indexOf(" ") == -1) {

    //checking for the absence of newline characters in the string

    if (myString.indexOf("\n") == -1) {

      //checking for absence of tab characters in the string

      if (myString.indexOf("\t") == -1) {

          return true;

      }

    }

  }

}

}

 return false;

}

Explanation:

The method takes a string presumed to be an email address and verifies whether it is valid, returning true if it is valid and false otherwise. The method checks the following conditions:

->The presence of the "@" character

->Only one occurrence of "@" exists in the string

->No spaces present

->No newline characters present

->No tab characters present

Returning true only if all these conditions are met.

You might be interested in
Server farms such as Google and Yahoo! provide enough compute capacity for the highest request rate of the day. Imagine that mos
Amiraneli [921]

Answer:

a) Energy conservation = 26.7%

b) Energy conservation = 48%

c) Energy conservation = 61%

d) Energy conservation = 25.3%

Explanation:

3 0
1 month ago
Start with the following Python code. alphabet = "abcdefghijklmnopqrstuvwxyz" test_dups = ["zzz","dog","bookkeeper","subdermatog
maria [879]

Answer:

alphabet = "abcdefghijklmnopqrstuvwxyz"

test_dups = ["zzz","dog","bookkeeper","subdermatoglyphic","subdermatoglyphics"]

test_miss = ["zzz","subdermatoglyphic","the quick brown fox jumps over the lazy dog"]

# From Section 11.2 of: # Downey, A. (2015). Think Python: How to think like a computer scientist. Needham, Massachusetts: Green Tree Press.

def histogram(s):

d = dict()

for c in s:

if c not in d:

d[c] = 1

else:

d[c] += 1

return d

#Part 1 Construct a function, called has_duplicates, that takes a string argument and returns True if there are any repeating characters present. If not, it should return False.

def has_duplicates(stringP):

dic = histogram(stringP)

for key,value in dic.items():

if value>1:

return True

return False

# Execute has_duplicates by building a histogram using the above histogram function. Implement a loop over the items in the test_dups list.

# Display each string and indicate whether it has duplicates based on the has_duplicates function's result for that string.

# For instance, the expected output for "aaa" and "abc" would be shown below. aaa has duplicates abc has no duplicates Display a similar message for each string within test_dups.

print("***Implementation of has_duplicates function***")

for sTr in test_dups:

if has_duplicates(sTr):

print(sTr+": has duplicates")

else:

print(sTr+": has no duplicates")

#Part 2 Develop a function named missing_letters that takes a string argument and returns a new string containing all alphabet letters absent from the input string.

#The letters in the resultant string should be arranged in alphabetical order. Your implementation must utilize the histogram from the previous function and should reference the global alphabet variable directly.

#It should iterate over the alphabet letters to figure out which are missing from the input string.

#The function missing_letters should merge the list of missing letters into a string and return it.

def missing_letters(sTr):

missingLettersList = []

dic = histogram(sTr)

for l in alphabet:

if l not in dic:

missingLettersList.append(l)

missingLettersList.sort()

return "".join(missingLettersList)

#Iterate over the strings in the test_miss list and invoke missing_letters for each one. Present a line for each string outlining the missing letters.

#For example, for the string "aaa", the output should be as follows. aaa is missing letters bcdefghijklmnopqrstuvwxyz

#Should the string encompass all alphabet letters, the output should indicate that it utilizes all the letters.

#For instance, output for the alphabet string itself would be: abcdefghijklmnopqrstuvwxyz uses all the letters

#Generate a similar line for each item in test_miss.

print("\n***Implementation of missing_letters function***")

for lTm in test_miss:

sTr = missing_letters(lTm.replace(" ",""))

if sTr!="":

print(lTm+" is missing letters "+sTr)

else:

print(lTm +" uses all the letters")

3 0
1 month ago
The Online Shopping system facilitates the customer to view the products, inquire about the product details, and product availab
amid [800]
Refer to the explanation provided. In the online shopping software system, five actors can be identified: A Customer can perform actions such as exploring products and seeking product information. The interface allows for the creation of customer accounts facilitating purchases. Additionally, customers can browse items by using search categories or keywords, and they are able to order and make payments for their selected products. The payment system accepts two primary methods: credit card and PayPal. A Seller can list products in appropriate categories and create accounts to gain membership. An Administrator manages product listings and can modify existing categories or introduce new ones. Finally, the Site Manager has the capability to view different reports regarding customer orders, seller-added products, and user-created accounts.
3 0
14 days ago
Write a program that allows the user to navigate the lines of text in a file. The program should prompt the user for a filename
amid [800]

This code is in Python. I'm not certain what programming language you need.

Refer to the image:

7 0
1 month ago
Read 2 more answers
Suppose we are sorting an array of eight integers using quicksort, and we have just finished the first partitioning with the arr
Rzqust [894]

Answer:

c. The pivot could either be 7 or 9.

Explanation:

When sorting an array of eight integers through quicksort, the first partitioning indicates that either 7 or 9 may serve as the pivot. Observing the array, it is specifically 7 and 9 that occupy their correct positions within the ordered array. All integers preceding 7 and 9 are lesser, and all numbers following them are greater. Therefore, it suggests that the pivot is located between 7 and 9.

6 0
20 days ago
Other questions:
  • A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate around the sun. To ac
    11·2 answers
  • Describe how the process of sampling, RGB pixels, and binary sequences work together to display a digital color image
    14·1 answer
  • Light travels at 3 × 108 meters per second. A light-year is the distance a light beam travels in one year.Write a PYTHON program
    14·1 answer
  • Create a different version of the program that: Takes a 3-digit number and generates a 6-digit number with the 3-digit number re
    14·1 answer
  • To finish creating a design for the webpage, use one shape to cut away part of the other. Create a 700 pixel by 700 pixel square
    10·1 answer
  • Henry, a graphic artist, wants to create posters. Which software should Henry use for this purpose?
    13·1 answer
  • The position of a runner in a race is a type of analog data. The runner’s position is tracked using sensors. Which of the follow
    8·1 answer
  • Which of the following is NOT true about data?
    8·2 answers
  • What problem does the DNS solve? How does the DNS help the world wide web scale so that billions of users can access billions of
    11·1 answer
  • Explain what might happen if two stations are accidentally assigned the same hardware address?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!