In java
given the following code how would I validate that that upper case & lower case letters are are ignored and accepted as the same?
// TODO add your handling code here:
String name = nameTextField.getText().trim();
if(name.isEmpty()){
JOptionPane.showMessageDialog(this, "Username field is empty.
Please correct.");
return;
}
if(name.indexOf(" ")!=-1){
JOptionPane.showMessageDialog(this, "Username field cannot contains
space in it. Please correct.");
}
Answer:
String name = nameTextField.getText().trim();
name = name.toLowerCase();
if(name.isEmpty()){
JOptionPane.showMessageDialog(this, "Username field is empty.
Please correct.");
return;
}
if(name.indexOf(" ")!=-1){
JOptionPane.showMessageDialog(this, "Username field cannot contains
space in it. Please correct.");
}
Explanation: java provides toLowerCase() method which converts all characters of the string into lowercase letter. So when you read a name convert it into lower case and then validate.
In java given the following code how would I validate that that upper case & lower...
Create a program via Java that has atleast 8 characters long, one upper case, and one lower case, and one digit. here is my code: public static void main(String[] args) { //variables defined String passwords; char password =0; //settings up password condition to false boolean passwordcondition= false; boolean size=false; boolean digit=false; boolean upper=false; boolean lower=false; //inputting a scanner into the system Scanner keyboard = new Scanner(System.in);...
in java language please
Question 2 (14 marks) a) Complete the following UML diagram as lava classes (8 marks): Write a constructor for Computer ser class based on the information you have in the UML Complete the hasSpaces method to check if a string has space or not il. Extend ComputerUser class with two subclasses, as shown below in UML diagram and write the appropriate methods listed in the UML diagram <<abstract>> ComputerUser # username: String #password: String + Computer...
Question- How would I allow the program to run both upper and lower case letters. How would I write a switch statement for upper and lower cases to see if the value entered for Grade2 is a A or a? C programming int main() { char Grade2; float gradepoint; char Grade = 'X'; // Declares a character type variable named Grade printf("Enter a grade\t"); // Prompts for Grade scanf("%c", &Grade); // Inputs Grade printf("Grade is: \t%c\n", Grade); // Prints the...
1. Given any word x (e.g. 'sTrInG'), how to make only the first letter upper case, and all other letter lower case? Given a list of words such as list_word = ['MS-Word','MS-Excel','Target','Walmart'……], please write a one line command to extract a sublist that only contains the items starting with 'MS'
In java write a command-line program that helps to decrypt a message that has been encrypted using a Caesar cipher1. Using this method, a string may contain letters, numbers, and other ASCII characters, but only the letters (upper- and lower-case) are encrypted – a constant number, the shift, is added to the ASCII value of each letter and when letters are shifted beyond ‘z’ or ‘Z’ they are wrapped around (e.g. “Crazy?” becomes “Etcba?” when shifted by 2). When your...
Please Use C++ Language. Thank you. Please I need the actual code. Donot post psudocode!! And also I have codes but just donot work so make sure that it works. Requested files: CrosswordGenerator.cpp, CrosswordGenerator.h, CrosswordGenerator_test.cpp CrosswordGenerator - Write a program that helps to generate a crossword puzzle by organizing words that share letters. For this assignment, you will write a program that forms the basis of a crossword puzzle generator. In order to create a crossword puzzle you need to...
Complete code and answer question in comments: Package hw4; import java.util.ArrayList; public class WordGame { /* * Returns all strings that appear * as a consecutive horizontal or vertical sequence of letters * (left-right, right-left, up-down, or down-up) * in the array board and also appear in dict. * Note that the same word may appear multiple times * on the board, and will then be multiple times in * the returned array. * * dict is assumed to be...
write the following code in java thank you and if you can, could you please write the code in replit and sent me a link to it replit is basically like a online compiler and you can write java code on it thank you The first part is to implement one of the questions from your examination. /* A Range objects represents an integer range, such as 1-10 or 50701-50799. The lower and upper bounds of a Range are given...
For this assignment, you will use your knowledge of arrays and ArrayLists to write a Java program that will input a file of sentences and output a report showing the tokens and shingles (defined below) for each sentence. Templates are provided below for implementing the program as two separate files: a test driver class containing the main() method, and a sentence utilities class that computes the tokens and shingles, and reports their values. The test driver template already implements accepting...