EBK JAVA PROGRAMMING
8th Edition
ISBN: 9781305480537
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
expand_more
expand_more
format_list_bulleted
Question
Chapter 7, Problem 4PE
Program Plan Intro
Program to display valid and invalid password
Program plan:
Filename: “ValidatePassword.java”
- Define the “ValidatePassword” class
- Declare the required variables and set the values.
- Create an object for scanner class.
- Prompt the user to enter the password.
- Read the length of the string and store it in a variable.
- Using, if…else condition check whether the string contains two uppercase, 3 lowercase and one digit.
- If the condition is satisfied, print the string as valid password, else print as invalid password.
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
Write an application that allows a user to enter any number of student test scores until the user enters 999. If the score entered is less than 0 or more than 100, display an appropriate message and do not use the score. After all the scores have been entered, display the number of scores entered, the highest score, the lowest score, and the arithmetic average. Save the file as TestScoreStatistics.cpp.
Write an application that determines whether the first two files are located in the same folder as the third one. If the files are in the same folder display All files are in the same folder, otherwise display Files are not in the same folder.
Test the program when the files are in the same folder and when they are not.
import java.nio.file.*;
import java.io.IOException;
public class CompareFolders {
public static void main(String[] args) {
Path file1 = Paths.get("/root/sandbox/TestData1.txt");
Path file2 = Paths.get("/root/sandbox/TestData2.txt");
Path file3 = Paths.get("/root/sandbox/test/TestData3.txt");
// Write your code here
}
}
Which of the methods below is a correct implementation of the functionality described in this Javadoc comment?
/** * This method returns a value that is twice as large as the provided * integer argument. * * @throws IllegalArgumentException if the provided number is negative. */
Group of answer choices
public int increase1(int number) throws IllegalArgumentException { return number * 2; }
public int increase(int number) { try { if (number < 0) { throw new IllegalArgumentException(); } else { return number * 2; } } catch (IllegalArgumentException e) { System.out.println("Negative number!"); } }
public int increase(int number) { if (number < 0) { throw new IllegalArgumentException(); } return number * 2; }
public int increase(int number) { if (number >= 0) { return number * 2; } else { return IllegalArgumentException; } }
Knowledge Booster
Similar questions
- Create a file named Store.Java. In that file, create a method with the following signature: public static double calculateRetail(double wholesale, double markup) This method should calculate how much a product should sell for based on the wholesale price and markup percentage. Make a Java code that results like test case examples.arrow_forwardPlease, I need help with this assignment, please. I pasted the HTML file and JavaScript file at the bottom of the instruction. Thank you so much. Murach's JavaScript and jQuery 4th edition by MARY DELAMATER (Chapter 12) Develop a password generatorIn this exercise, you’ll develop an application that generates strong passwords of the length entered by the user.1. In the JavaScript file, note the getRandomNumber() function. Also, note that the ready event handler contains the handler for the click event of the Get Password button and the handler for the click event of the Clear button. The handler for the Get Password button clears the password text box and has a constant named chars that contains some characters. The handler for the Clear button resets the text boxes and moves the focus to the first text box.2. In the handler for the Get Password button, get the value entered by the user and make sure it’s a number. If it isn’t, display an alert dialog box with this message: “Please…arrow_forwardCreate a file named Validate.java , in that file create a method with the following signature: public static String getName(Scanner keyboard) Given a keyboard, make this method ask the user for a name. Ensure the name is between 5 and 15 characters. Return that name from this method. Write in java and use test case# as an examplesarrow_forward
- The Java class that we use to allow the user to navigate through folders and select a file is called : a) JFileSelect b) InFile c) JFileChooser d) This is not an option in Java.arrow_forwardWrite an application that displays the result of dividing two numbers and displays anyremainder. The main() method prompts the user for values and sends them to the dividingmethod; the dividing method performs the calculation and displays the results. Save theapplication as Divide.csarrow_forwardPlease answer the correct option and its reasoning. int loc; String str = "The cow jumped over the moon."; loc = str.indexOf("ow"); What is the value of loc? 1. 5 2. 6 3. 4 4. 7arrow_forward
- create an application that will ask the user to enter passwordset in the program for only three times. Once the user fails to enter the correct passwordfor three consecutive times, he/she will not be able to proceed with the quiz. The quizshould contain at least five questions about a hobby, popular music, astronomy, or anyother personal interest. The question should be in multiple choice and responses couldbe a, b, c, or d. After answering all the questions, the total number of correct answersshould appear immediately.arrow_forwardUsing the objects you just created, as shown below, call the method to change the access level to the next in the sequence (in C++). CODE: #include <iostream>using namespace std; class ParkingLot {private: bool Paid; bool Up; bool Down; public: ParkingLot() { Paid = false; Up = false; Down = true; } ParkingLot(bool paid, bool up) { Paid = paid; Up = up; Down = !up; } void togglePaid() { Paid = !Paid; if (Paid) { Up = true; Down = false; } else { Up = false; Down = true; } } bool isPaid() { return Paid; } bool isUp() { return Up; } bool isDown() { return Down; }}; int main() { // create a ParkingLot object using the default constructor ParkingLot lot1; // create a ParkingLot object using the overloaded constructor ParkingLot lot2(true, false); // display initial state of the…arrow_forwardWrite an application that reads three nonzero values entered by the user and determines and prints whether they could represent the sides of a triangle. *the needed prompts/ output is shown in the screenshot highlighted in grey and yellow* In Java.arrow_forward
- I would like to open a data file in Java for Exercise 6 in Chapter 4 of JAVA by Gaddis & Muganda. The file properties shows in Explorer the location as C: \Users\Vladi\Desktop. The Files is Exercise0406.txt. I inserted the lineFile file = new File(“C:\Users\Vladi\Desktop\Exercise0406.txt”);I get Exception cannot find file.arrow_forwardplease use java to answer the following question Implement a program with a GUI and Action listener that looks like the one shown below You should connect to the database ( make sure you have maximum 5 rows in your table) The table should contain of the name, card number and the pin number of the customers who uses the ATM once you enter the card number and the pin number that exist in the database, then by clicking on the Login button, you could show a dialogue dialog box in which it shows the name of the customer and then indicates that that name is login successfully ( Mehrnaz is login successfully). Otherwise, the dialogue box indicates that the information does not exist in the database. The clear button will clear all the information on the GUI.arrow_forwardPrint a message telling a user to press the letterToQuit key numPresses times to quit. End with newline. Ex: If letterToQuit = 'q' and numPresses = 2, print:Press the q key 2 times to quit. #include <iostream>using namespace std; int main() { char letterToQuit; int numPresses; cin >> letterToQuit; cin >> numPresses; /* Your solution goes here */ return 0;}arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage