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
In Python, if var1 = "Happy" and var2= "Birthday" and var3 = (var 1+var2) *2, then var3 stores the string
nordsb [41]

Answer:

The answer is "Option A".

Explanation:

The program to the given question can be given as:

program:

var1 = "Happy" #defining variable var1

var2= "Birthday" #defining variable var2

var3 = (var1+var2) *2 #defining variable var3 and calculate value

print (var3) #print value.

Output:

HappyBirthdayHappyBirthday

In the above python program, three variable is defined, that is var1, var2, and var3, in which variable var1 and var2 we assign a value, that is "Happy" and "Birthday".

In variable var3 we add the value of var1 and var2 variable and multiply by 2. It will print the variable value two times. and other options are not correct that can be defined as:

  • In option B and C, Both variable var1 and var2 print there values two times but in option B var1 value print two time and var2 value print one time only and option C var1 variable value is print only one time and var2 variable value is print two times that's why it is not correct.
  • In option C, Both variable var1 and var2 print there values two times that's why it is not correct.

7 0
2 years ago
What is outlook used for?
Arte-miy333 [17]
Outlook is used for mainly emails. It also keeps track of your calendar, has contact and tasks.
4 0
2 years ago
Read 2 more answers
...............................
Gemiola [76]

............................

Mark me brainliest^^

7 0
2 years ago
Read 2 more answers
. Convert your age into binary and then to hexadecimal. Show your work.
Dovator [93]

Explanation:

Age = 23.

To convert a base 10 number to hexadecimal number we have to repeatedly divide the decimal number by 16 until  it becomes zero and store the remainder in the reverse direction of obtaining them.

23/16=1 remainder = 5

1/16=0 remainder = 1

Now writing the remainders in reverse direction that is 15.

My age in hexadecimal number is (15)₁₆.

5 0
3 years ago
When an IPv6 device with no pre-configured IPv6 address powers up, it can calculate a global 128-bit IPv6 address for itself usi
RSB [31]

Answer:

True

Explanation:

IPv6 Is a later version of IP addresses, used to solve the problem of the limited number of IPv4 addresses in the network.

Just like IPv4, IPv6 can also is configured to a device statically and dynamically. Dynamic IPv6 configuration could be a stateless autoconfiguration SLAAC, a stateless DHCPV6 or a stateful DHCPV6.

The IPv6 address is configured with a prefix and a prefix length and a EUI generated 64 bit interface or a random interface id by the device.

8 0
3 years ago
Other questions:
  • What is the reason that a modern electron microscope (TEM) can resolve biological images to the subnanometer level, as opposed t
    9·1 answer
  • Write a Python function called validateCreditCard that takes 8-digit credit card number as the input parameter (string value) an
    8·1 answer
  • Whats the size of a short bond paper in microsoft word?
    10·1 answer
  • How much time does a gold chest take to open
    11·1 answer
  • Write a complete Java method that returns an integer. The method declares a Scanner object, then prompts the user for a series o
    12·1 answer
  • Cuáles eran las condiciones de vida de las mujeres durante el renacimiento perduran​
    14·1 answer
  • _______________ ________________ have human editors that evaluate, select, and organize websites into a hierarchy of categories.
    11·1 answer
  • How would a person giving a persuasive speech use projection to make a key point?
    9·2 answers
  • ASAP BRAINLIEST!!!!!!
    5·2 answers
  • What is boot sector virus​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!