2_ob85_meet

.docx

School

Drexel University *

*We aren’t endorsed by this school

Course

431

Subject

Computer Science

Date

May 1, 2024

Type

docx

Pages

4

Uploaded by bbbtobi17 on coursehero.com

Tobi Bakare 04/13/2024 Week2Meet - 10 pts =============================== Reading a program Write pseudocode for the GenerateCode program. /*************************************** * GenerateCode.java – name of the program * random passphrase program – the aim of the program * * @author Tammy Pirmann – author * @version 1.0 – version of the coder ****************************************/ import java.util.Scanner; - importing class scanner used to get user input, import java.util.Random; - importing random generator class GenerateCode { - - class name ( must be the same as the name of file) public static void main (String args[]){- the main method used to run a program Random randGen = new Random(); - create a new random instance Scanner keyboard = new Scanner(System.in); - create scanner object “keyboard” to read input System.out.println("Welcome to the Code Generator! \n Answer some questions and I will generate a set of codes for your consideration."); - print out the phrase System.out.println("The name of a loved one: "); - print out the phrase String lovedOne = keyboard.next(); - asking for an input keyboard.nextLine(); - moving the input to the next line. … …. keyboard.close(); - close scanner object keyboard int number = (randGen.nextInt(8))+2; String shortFvrt = favorite.replace('a', ' '); - replaces the favorite food vowel with a space, in this case the vowel ‘a’
shortFvrt = shortFvrt.replace(" ", ""); - replaces the favorite food space with no space. … …. System.out.printf("Code #1: %s%d%s\n", lovedOne, year, shortFvrt); - print out the random phrase in this order with three of the inputs … …. System.out.printf("Code #3: %s%d%s%d\n", lovedOne, number, place, year); - print out the random phrase in this order with four of the inputs … …. } } --------------------------------------------------------------------------------------------------------------------- ------ I understand the problem introduced in class to be: (in your own words) The problem introduced in class was aimed to generate random phrases from common words we like and know while also learning how to use int, replace and random number. This phrase could be useful in creating passwords also. My plan to solve this problem is: to get input for each part of the random phrase and put them together. The solution to the problem was the following program: (provide the name of the .java file only) GenerateCode.java I tested the solution with at least 3 different value sets. The test data and results are: (use this format: var1 = data, var2 = data, etc -> result)
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help