Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

String keyWord is read from input. For each character in keyWord that is a digit, increment count by 1 . Then, output Valid if count

String keyWord is read from input. For each character in keyWord that is a digit, increment count by 1. Then, output "Valid" if count contains at least 2 digits and keyWord's length is greater than 5. Otherwise, output "Invalid". End each output with a newline.
Click for examples
Ex 1: If the input is t07TBs, then the output is:
Valid
Ex 2: If the input is jq31b, then the output is:
Invalid
Note: Character.isDigit() returns true if a character is a digit, and false otherwise. Ex: Character.isDigit('8') returns true. Character.isDigit('a') returns false.
import java.util.Scanner;
public class ValidInvalid {
public static void main(String[] args){
Scanner scnr = new Scanner(System.in);
String keyWord;
int i;
int count;
keyWord = scnr.next();
count =0;
/* Your code goes here */
}
}

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_2

Step: 3

blur-text-image_3

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

Describe the appropriate use of supplementary parts of a letter.

Answered: 1 week ago