1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Alexxandr [17]
2 years ago
5

This question involves the implementation of the PasswordGenerator class, which generates strings containing initial passwords f

or online accounts. The PasswordGenerator class supports the following functions:
- Creating a password consisting of a specified prefix, a period, and a randomly generated numeric portion of specified length
- Creating a password consisting of the default prefix "A", a period, and a randomly generated numeric portion of specified length
- Reporting how many passwords have been generated

The following table contains a sample code execution sequence and the corresponding results: Statements, Possible Value Returned (blank if no value returned), Comment

PasswordGenerator pw1 = new
PasswordGenerator(4, "chs");
(blank)
Passwords generated by the pw1 object are composed of the prefix "chs", a period, and 4 randomly-generated digits.
pw1.pwCount();
0
No passwords have been generated yet.
pw1.pwGen();
"chs.3900"
A possible password generated by the pw1 object
pw1.pwGen();
"chs.1132"
A possible password generated by the pw2 object
pw1.pwCount();
2
Two passwords have been generated. Both contain the prefix "chs" and 4 digits.
PasswordGenerator pw2 = new
PasswordGenerator(6);

Passwords generated by the pw2 object are composed of the default prefix "A", a period, and 6 randomly generated digits.
pw2.pwCount();
2
Two passwords have been generated. Both contain the prefix "chs" and 4 digits.
pw2.pwGen();
"A.843055"
A possible password generated by the pw2 object
pw2.pwCount();
3
Three passwords have been generated. Two contain the prefix "chs" and 4 digits, and the third contains the default prefix "A" and 6 digits.
pw1.pwCount();
3
Three passwords have been generated. The same value is returned by pwCount for all objects of the PasswordGenerator class.

Write the complete PasswordGenerator class. Your implementation must meet all specifications and conform to the example.
Computers and Technology
1 answer:
liq [111]2 years ago
8 0

The following code will be used for the PasswordGenerator class.

<u>Explanation:</u>

import java.util.Random;

public class PasswordGenerator {

   private static int passwordsGenerated =0;

   private static Random random = new Random();

   private String prefix;

   private int length;

   public PasswordGenerator(int length,String prefix) {

       this.prefix = prefix;

       this.length = length;

   }

   public PasswordGenerator(int length) {

       this.prefix = "A";

       this.length = length;

   }

   public String pwGen(){

       String pwd= this.prefix+".";

       for(int i=1;i<=this.length;i++){

           pwd+=random.nextInt(10);

       }

       passwordsGenerated+=1;

       return pwd;

   }

   public int pwCount(){

       return passwordsGenerated;

   }

   public static void main(String[] args) {

       PasswordGenerator pw1 = new PasswordGenerator(4,"chs");

       System.out.println(pw1.pwCount());

       System.out.println(pw1.pwGen());

       System.out.println(pw1.pwGen());

       System.out.println(pw1.pwCount());

       PasswordGenerator pw2 = new PasswordGenerator(6);

       System.out.println(pw2.pwCount());

       System.out.println(pw2.pwGen());

       System.out.println(pw2.pwCount());

       System.out.println(pw1.pwCount());

   }

}

You might be interested in
If you want to change the speed of a layer's horizontal scrolling, what should you change?
kirill [66]

Answer: A; X coefficient

Explanation: Hope I helped out !

-Carrie

Ps. it would mean a lot if you marked brainliest

6 0
3 years ago
Justify the first two paragraphs and the tips list.
Ket [755]

Answer:

dont mind me just hwere is your question i literaly can see it anywhere

Explanation:

4 0
3 years ago
What are some of the challenges that could arise from setting up a file management system on a computer?
emmainna [20.7K]
File management is set of methods for naming, storing and handling files. <span>A few key things that should be taken into consideration are: date, genre, occasion, and subject. After setting up a file management system on a computer the following challenges could arise: </span>standardize file naming, folder structure, metadata use and more. .
5 0
3 years ago
Given a floating-point variable fraction, write a statement that writes the value of fraction to standard output. Do not write a
sertanlavr [38]

Answer:

The statement to this question is "cout << fraction;".

Explanation:

In the given question it is declared, that a floating-point variable "fraction" is defined, which holds some value. To print this variable value in C++ program we use the print function, which is "cout". This function also used to print messages and values, in this question the print function uses the float variable "fraction", which prints variable value.

8 0
3 years ago
On laptops, wireless cards tend to be attached to which panel?
Arada [10]

Answer:

NONE of the above   to fix  wireless  cards to be attached to any panel

Explanation:

Basically, the WiFi receiver and transmitter are fixed in the mother of the laptop and fixed. In case if we   open the laptop if PCI slot is   available   and suitable WiFi card and able fit it  to size then   end user he or she  can fixed and  try

The hard drive is the backside of the laptop. If e place the WiFi system will able to boot.

LCD panel it is just displayed out the unit and  its  fixed in a different  place and connected to led or LCD panel

Palm rest it places where there is no slot available  

Ram panel if we fix WiFi card then the laptop will not start.

Better by USB dongle and use it.

5 0
3 years ago
Other questions:
  • What software refers to the on authorized and illegal duplication or sale of software
    10·1 answer
  • [Submit on zyLabs] Please write a function with one input, a matrix, and one output, a matrix of the same size. The output matri
    10·1 answer
  • What is the output of the following function if the array nums contains the values 1 2 3 4 5 int backwards(int nums[]) { for (x
    15·1 answer
  • PLEASE HELP, THANK YOU SO MUCH!
    13·1 answer
  • What’s bigger 4,000,000 KB or 2.8 GB
    5·2 answers
  • Write a C++ program to count even and odd numbers in array. The array size is 50. The array elements will be entered by the user
    13·1 answer
  • Outline the dangers arising as a result of using computers​
    12·1 answer
  • Which of the following is the biggest issue facing wireless communication today?
    5·1 answer
  • How would you design an adaptive environment for people who are blind?
    10·1 answer
  • Fort Nite is the best u can’t say it’s not
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!