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
Montano1993 [528]
3 years ago
12

Write a function named "isValidPassword" that takes in a string and returns 1 if it stores a valid password and 0 otherwise, A v

alid password must contain at least one lowercase letter, one uppercase letter, and at least one nonletter character. Example: if input string is Example: if input string is "Pass_word", function should return "1" "password", function should return "0"
Computers and Technology
1 answer:
Maslowich3 years ago
8 0

Answer:

Here is code in java.

import java.util.*;

import java.lang.*;

import java.io.*;

class Solution

{

public static void main (String[] args) throws java.lang.Exception

{

   try{

   //declare and initialize string variables

       String str1="password";

       String str2="Pass_word";

    //calling function to check valid password

       System.out.println("output of password is: "+isValidPassword(str1));

        System.out.println("output of Pass_word is: "+isValidPassword(str2));

   }catch(Exception ex){

       return;}

}

// functionn to check the valid password

public  static int isValidPassword(String str)

{

// variables to count the lower,upper and non character

  int i, lower_c = 0, upper_c = 0, non_c = 0;

  char ch;

  for(i=0;i<str.length();i++)

  {

      ch = str.charAt(i);

     if(ch >= 'a' && ch <= 'z')

     {//count of lower character

        lower_c++;

     }

     else if(ch >= 'A' && ch <= 'Z')

     {

   //count of upper character

        upper_c++;

     }

     else

     {

   //count of non character

        non_c++;

     }

  }

  if(lower_c > 0 && upper_c > 0 && non_c > 0) {

     return 1;

  } else {

     return 0;

  }

}

}

Explanation:

Declare and initialize two string variables.In the isValidPassword() function, pass the string parameter and then count the lower, upper and non character in the string.If string contains call the three characters then function will return 1 otherwise it will return 0 .

Output:

output of password is: 0

output of Pass_word is: 1

You might be interested in
Linda subscribes to a cloud service. The service provider hosts the cloud infrastructure and delivers computing resources over t
siniylev [52]

Answer

Public cloud

Explanation

A cloud service is any service that is made available to users who are on demand via internet from the cloud computing service providers.  These service providers have servers in their company premises where they offer the services from.

A public cloud is a type of computing in which a service provider makes resources available to the public via the internet. The service provider hosts the cloud infrastructure and delivers computing resources over the Internet Resources vary by provider but may include storage capabilities, applications or virtual machines.


3 0
3 years ago
Create the strAnalysis() function that takes 1 string argument and returns a string message. The message will be an analysis of
nydimaria [60]

Answer:

def str_analysis(s):

   if s.isdigit():

       s = int(s)

       if s > 99:

           message = str(s) + " is a pretty big number"

       else:

           message = str(s) + " is a smaller number than expected"

       

   elif s.isalpha():

       message = s + " is all alphabetical characters!"

   else:

           message = "There are multiple character types"

   

   return message;

   

s = input("enter word or integer: ")

while s != "":

   print(str_analysis(s))

   s = input("enter word or integer: ")

Explanation:

- Check if the string is digit, alphabetical, or mixed inside the function

- Ask the user for the input

- Call and print the result of the <em>str_analysis</em> function inside the while loop

- Keep asking for the input until the given string is empty

7 0
3 years ago
A media file refers to what kind of file? A. Clip art
prohojiy [21]

Waveform Audio (.wav) is a common file format. Created by Microsoft and IBM, WAV was one of the first audio file types developed for the PC. WAV files are defined as lossless, meaning that files are large and complete; nothing has been lost.

your answer will be

<h2><em><u>C; image</u></em></h2>
5 0
3 years ago
Read 2 more answers
Pls someone help me with these four questions
ipn [44]

Answer:

16. Grace Hopper. 1959.

8 0
2 years ago
Guys Do you know about e-waste recycling well ?
TEA [102]
<span>E-waste is a popular name for elecronics at the end of their "useful life".. computers, tv, steros, copiers, and fax mations are some common products. many of them can be reused, refurbished, or recycled. 
</span>
4 0
2 years ago
Read 2 more answers
Other questions:
  • Which Internet resource can you use to publicly describe an adventure trip you recently made?
    9·1 answer
  • How is marketing related to the other functions of a business
    14·1 answer
  • Which of the following best describes a group?
    13·1 answer
  • When compared to traditional desktop customers, why are mobile phone users much more likely to book a room or airline reservatio
    12·1 answer
  • What do you need for digital photography? 1. 2. 3.
    13·1 answer
  • Which of the following contributes to your active digital footprint
    12·2 answers
  • Janet received an email from a bank asking for the password for her Internet banking account. She emailed back her password. A f
    12·2 answers
  • What is a geam in the ggplot2 system?
    5·1 answer
  • You are setting up a home network for your friend. She has students visiting her home regularly for lessons and wants to provide
    14·1 answer
  • write code that removes the first and last elements from a list stored in a variable named my_list. assume that the list has bee
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!