Question

Introduction to Java programming You will create a secure password. Ask a user to enter first...

Introduction to Java programming

You will create a secure password.

  • Ask a user to enter first name and last name. (Allow for mixed case)
  • Create a random integer from 10-99.
  • Create the password string that consists of the upper case letter of the last letter of his/her first name, the random number, and the first three letters of his/her last name in lower case.
  • Example someone with the name Rob Lee might have a password that looks like B56lee.
  • Your print out should then include the person's name and new password in the following format:
  • Rob Lee's password is: "B56lee"

You program must dynamically determine the last character from the first name. Do not hardcode the number.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
// PasswordGenerator.java

import java.util.Random;
import java.util.Scanner;

public class PasswordGenerator {

        public static void main(String[] args) {
                
                Scanner sc = new Scanner(System.in);
                Random rand = new Random();
                
                // range of numbers from low to high
                int low = 10;
                int high = 99;
                
                // reading first name and last name
                System.out.print("Enter first name  : ");
                String fname = sc.next();               
                System.out.print("Enter last name   : ");
                String lname = sc.next();
                
                // generating random number
                int randNum = rand.nextInt(high-low) + low;
                
                // extracting last character from first name and converting to upper case
                String lastChar =  Character.toString(fname.charAt(fname.length()-1)).toUpperCase();

                // extracting first 3 characters from lastname
                String first3Chars = lname.substring(0,3);
                
                String password = lastChar + randNum + first3Chars;
                
                System.out.println(fname +" "+ lname+"'s password is : \""+password+"\"");
                
                sc.close();
        }

}

Output:

#1

Console X X <terminated> Password Generator [Java Application] C:\Program Files Enter first name : Rob Enter last name : Lee

#2

<terminated> Password Generator (Java Application] C:\Program Files Enter first name : Vergara Enter last name : Sofia Vergar

Add a comment
Know the answer?
Add Answer to:
Introduction to Java programming You will create a secure password. Ask a user to enter first...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create a simple Java class for a Password with the following requirements:  This program will...

    Create a simple Java class for a Password with the following requirements:  This program will have a header block comment with your name, the course and section, as well as a brief description of what the class does.  One String property: password (protected to only allow secure passwords) o A secure password must be at least 8 characters in length o A secure password must have three of the following four requirements:  A lower case letter ...

  • Lab Assignment – Database Implementation and Security In this lab you will create a Microsoft Access database of employee information and secure the table username and password security. Steps Enter...

    Lab Assignment – Database Implementation and Security In this lab you will create a Microsoft Access database of employee information and secure the table username and password security. Steps Enter data for five employee records. Each record should have fields: Employee ID (5 digits), First Name, Last Name, Home Address, Hire Date Create a query that displays Employee ID, First Name and Last Name. Create a form that requires entering username and password to access employee table. Error message should...

  • I have to use java programs using netbeans. this course is introduction to java programming so...

    I have to use java programs using netbeans. this course is introduction to java programming so i have to write it in a simple way using till chapter 6 (arrays) you can use (loops , methods , arrays) You will implement a menu-based system for Hangman Game. Hangman is a popular game that allows one player to choose a word and another player to guess it one letter at a time. Implement your system to perform the following tasks: Design...

  • (Java) HELP! Create a program that will ask the user to enter their first name and...

    (Java) HELP! Create a program that will ask the user to enter their first name and their favorite number. Ask the user if they would like the information repeated back to them. If they type "Y" display the answers back to them. If they type anything else, display the word "Goodbye". An example of what your output window should look like is below. The system-generated output is in red. The user-provided input is in green. (Your actual program will only...

  • in a java application need  to create an application which prompts the user numerator and denominator values...

    in a java application need  to create an application which prompts the user numerator and denominator values then show the result of the division.  The application will use exception handling to verify the user has entered valid input and will continue to prompt the user for input as long as the value they enter is invalid.  Once the user has entered valid numerator and denominator values, the result is shown and the application exits. had some issues when I entered letters instead of...

  • I need Pseudocode Algorithm only, please Write a program that asks the user to enter the...

    I need Pseudocode Algorithm only, please Write a program that asks the user to enter the name of his or her favorite city. use a String variable to store the input. The program should display the following: The number of characters in the city name the name of the city in all uppercase letters the name of the city in all lower case letters the first character in the name of the city

  • 1. Create a NetBeans project under the name PlayingWithJavaStrings. 2. In the source code do the...

    1. Create a NetBeans project under the name PlayingWithJavaStrings. 2. In the source code do the following: i) Create two separated String variables, one for the first and the other for the last names and set them to “John” and “Smith”, respectively. ii) Create a String variable for the full name and then concatenate the first and last name variables into it. 3. Using the String methods found in the Java API: Print the full name in the terminal window...

  • Introduction to computer class, Java programming through eclipse: Ue the following criteria to create the code:...

    Introduction to computer class, Java programming through eclipse: Ue the following criteria to create the code: SALARY Input first and last name - Output the names last, first in your output - Make the federal withholding rate a constant 20% (not an input value) No state tax Generate two new values: regular pay and overtime pay - 40 hours workedor less - Regular pay is pay rate * hours worked - Overtime pay is 0 Otherwise - Regular pay is...

  • JAVA Write a program that prompts the user to enter a year and the first three...

    JAVA Write a program that prompts the user to enter a year and the first three letters of a month name (with the first letter in uppercase) and displays the number of days in the month. If the input for month is incorrect, display a message as shown in the following sample run. SAMPLE RUN 1: Enter a year: 2001 Enter a month: Jan Jan 2001 has 31 days SAMPLE RUN 2: Enter a year: 2016 Enter a month: Feb...

  • cs55(java) please Part 1: You are a programming intern at the student transfer counselor's office. Having...

    cs55(java) please Part 1: You are a programming intern at the student transfer counselor's office. Having heard you are taking CS 55, your boss has come to ask for your help with a task. Students often come to ask her whether their GPA is good enough to transfer to some college to study some major and she has to look up the GPA requirements for a school and its majors in a spreadsheet to answer their question. She would like...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT