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
  • 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...

  • 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...

  • 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...

  • 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...

  • JAVA Overview Create a method public static void spongeBobify(String inputPath, String outputPath...

    JAVA Overview Create a method public static void spongeBobify(String inputPath, String outputPath, Mode mode) that will convert a file to Mocking Sponge Bob text in 3 different modes. EveryOther capitalize the first letter of the string capitalize every other letter (ignoring non-letter character like punctuation and spaces). non-letter characters don't count toward the every other count Example: mocking sponge bob! → MoCkInG sPoNgE bOb! Vowels capitalize every vowel (not including y) Random capitalize each letter with a probability of 35%....

  • Please answer number 5 CS500 Programming Problems Create a subdirectory of your home directory named sep16...

    Please answer number 5 CS500 Programming Problems Create a subdirectory of your home directory named sep16 (note the case). Save your solutions in that directory in files named pl.c, p2.c, p3.c, p4. c, and p5. c. Your programs are due Friday September 16 at 4:00PM. You will not receive any credit if your programs are late, have the wrong filename, or are in the wrong directory. 1. Write a C program that reads stdin one character at a time and...

  • JAVA PROGRAMMING File Name You can not just take the file and send it. When Polycarp...

    JAVA PROGRAMMING File Name You can not just take the file and send it. When Polycarp trying to send a file in the social network "Codehorses", he encountered an unexpected problem. If the name of the file contains three or more "x" (lowercase Latin letters "x") in a row, the system considers that the file content does not correspond to the social network topic. In this case, the file is not sent and an error message is displayed. Determine the...

  • Your task for this project is to write a parser for a customer form. You need to develop a Java a...

       Your task for this project is to write a parser for a customer form. You need to develop a Java application using Parboiled library. Your program should include a grammar for the parser and display the parse tree with no errors. Remember that your fifth and sixth assignments are very similar to this project and you can benefit from them. The customer form should include the following structure: First name, middle name (optional), last name Street address, city, state (or...

  • In this programming assignment we will review string and character manipulations. You will be developing a...

    In this programming assignment we will review string and character manipulations. You will be developing a Java program that will prompt users for person’s last name, year of birth, and employee number in a predefined specific format. You will then parse the input string and print it in separate lines along with validations. The input format will be of the form :,< employee number > You will need to separate three segments in order to print it as: Last name...

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
ADVERTISEMENT