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
Answer for a, b, and c
Darya [45]

The answer is a. im pretty positive but if im wrong super sorry

5 0
3 years ago
For activities with output like below, your output's whitespace (newlines or spaces) must match exactly. See this note. Jump to
Vinvika [58]

Answer:

The program to this question can be given as:

Program:

#include<stdio.h>//include header file

int main() //defining main method

{

printf("Hello..! and please vote the answer."); //print value.

return 0;

}

Output:

Hello..! and please vote the answer.

Explanation:

In the given question some information is missing that is the message to be printed, In this code assume some message to be displayed, and the description to the above code as follows:

  • In the above code firstly header file is included for using a basic function like print method, input method, etc.
  • In the next line main method is defined, inside the main method a print function is used in this function a message is passed with a double-quote ("'). When the code will execute it will print the message that is given in the output section.

5 0
3 years ago
You'd like to create remarketing lists based on your customer's journey through your website so that you can target them with di
Marat540 [252]
The term homepage visitors <span>describes the users that visited your homepage, but didn't move any further into your site. 
</span><span>Homepage denotes the main initial web page of a website.
</span><span>The first web page people see when they arrive on a website is also known as the "landing page".</span>
4 0
3 years ago
Which of the following is NOT a type of cable used in wired networks?a) Unshielded coaxialb) Coaxialc) Unshielded twisted-paird)
zysi [14]

Answer:

I think it is unshielded coaxial. Not 100% sure.

Explanation:

5 0
3 years ago
Check out this app! It's millions of students helping each other get through their schoolwork. https://brainly.app.link/qpzV02Ma
MrRa [10]

Answer:

Tamam hocam o zaman....

8 0
2 years ago
Other questions:
  • Which one of the following media is most resistant to EMI?
    11·1 answer
  • For your new sporting goods store, you originally planned to only sell Nike shoes. Therefore, you only had enough shoe displays
    11·2 answers
  • Garry is a record executive who is building a data table to include in a presentation about one of his artists. The table is mea
    15·1 answer
  • (fill in the blank) <br><br> ____ is when data is formatted, transmitted and received in a network.
    13·1 answer
  • Answer the queston...........​
    7·2 answers
  • What is the missing line of code? &gt;&gt;&gt; &gt;&gt;&gt; math.sqrt(16) 4.0 &gt;&gt;&gt; math.ceil(5.20) 6
    14·2 answers
  • How can I use HTML to express a personal value
    13·1 answer
  • Michelle has defined a custom object by creating an object literal. She wants to access the properties of the custom object. Mic
    10·1 answer
  • The Western Siberian Plain is __________ in some places because it has poor natural draining systems.
    15·1 answer
  • 9- Write a program in MARIE to add three numbers.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!