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
How are Action Buttons different than hyperlinks?
ipn [44]

Actions buttons are different than hyperlinks in many ways.

2)They are predefined shapes.

<u>Explanation:</u>

Action buttons are predefined shapes in the PowerPoint and can be used for moving between the slides of the presentation and for referring to the hyperlinks as well.

Action buttons have a predefined shape and that shape can be used to set the functionality of that particular button as a convention. Action buttons make up a strong presentation.

Action buttons can be invoked by clicking on them or just hovering over them and various sound effects can also be added on both the events to make the presentation more engaging and attractive.

8 0
2 years ago
When you ____ software, you are adapting it from one type of computer or operating system to run on a different computer or oper
ra1l [238]

Answer: Port

Explanation :

When we port a software from one computer to another computer or from one operating system to another operating system, it tries to adapt to the new environment of the machine by checking the required the configurations of the machine and then checking the available files in the software to run the machine.

The porting of a software also checks whether the software is compatible with the machine or not and if not then why.

7 0
3 years ago
Match each of the following steps of SDLC development to its position in the development process.
Arisa [49]

Answer:

Step One - problem/opportunity identification  (V)

Step Two - Analysis (III)

Step Three - Design (II)

Step Four - Development (I)

Step Five - Testing and Installation (IV)

Explanation:

In the field of software development, or systems engineering, SDLC which refers to software development cycle refers to a systematic way of building software applications, it shows unique stages with the outcome of each stage dependent on the previous, step has a unique task which range from the planning, analysis, development, testing and installation of the information system.

5 0
3 years ago
Make a hierarchical directory structure under /root that consists of one directory containing three subdirectories.
Alika [10]
You can make a hierarchical directory structure under /root that consists of one directory containing subdirectories  by using cd and mkdir
the mkdir command created the directories while the cd command changes which directory you're currently in
5 0
2 years ago
Photographing during the midday can produce which of the following?
deff fn [24]
It can produce harsh shadows
5 0
2 years ago
Read 2 more answers
Other questions:
  • Pedestrians, cyclists, horse drawn vehicles and wheel chair users are known as ___________
    6·2 answers
  • Write an expression to print each price in stock_prices. sample output for the given program: $ 34.62 $ 76.30 $ 85.05
    6·1 answer
  • Write multiple if statements. if caryear is 1969 or earlier, print "probably has few safety features." if 1970 or higher, print
    6·1 answer
  • How to reinstall windows 7 on my pc,without format,because i don't want to loose my data,and can u give me a windows 7 setup ple
    8·1 answer
  • Briley has all the hardware she needs to construct a fully functional personal computer. She connects the various components and
    7·1 answer
  • Who found the first computer bug in 1947, and invented the concept of a compiler in 1952
    6·1 answer
  • Windows Rights Management Services is used in conjunction with which Microsoft applications?
    11·1 answer
  • Queremos conectar una pila de 4,5 V a un diodo LED cuya tensión de trabajo es de 2 V. Calcula cuál debe ser el valor de la resis
    8·1 answer
  • How is knowing how to use word or docs importamt?
    8·1 answer
  • A leading global vendor of computer software, hardware for computer, mobile and gaming systems, and
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!