Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Read a 2 - character string from input into variable inputString. Declare a Boolean variable isValid and assign isValid with true if inputString does not

Read a 2-character string from input into variable inputString. Declare a Boolean variable isValid and assign isValid with true if inputString does not contain any lowercase letters. Otherwise, assign isValid with false.
Ex: If the input is =C, then isValid is assigned with true, so the output is:
String accepted
Ex: If the input is mf, then isValid is assigned with false, so the output is:
String not accepted
Note: Use inputString = scnr.nextLine() to read the entire line from input into inputString.
import java.util.Scanner;
public class StringModification {
public static void main(String[] args){
Scanner scnr = new Scanner(System.in);
String inputString;
/* Your code goes here */
if (isValid){
System.out.println("String accepted");
}
else {
System.out.println("String not accepted");
}
}
}

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

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Management Systems

Authors: Patricia Ward, George A Dafoulas

1st Edition

1844804526, 978-1844804528

More Books

Students also viewed these Databases questions

Question

Identify the motives that fuel prejudice.

Answered: 1 week ago

Question

A 300N F 30% d 2 m Answered: 1 week ago

Answered: 1 week ago

Question

Write a letter asking them to refund your $1,500 down payment.

Answered: 1 week ago