Write a program that prompts the user to enter a Social Security number in the format ddd-dd-dddd, where d is a digit. The program displays Valid SSN for a correct Social Security number or Invalid SSN otherwise.

Answers

Answer 1
Answer:

The program that prompts the user to enter a Social Security number in the format ddd-dd-dddd, where d is a digit can be implemented in Python using regular expressions. The regular expression pattern for the SSN format can be used to validate the input.

Pythons code:

```python

import re

ssn_pattern = re.compile(r'^\d{3}-\d{2}-\d{4}$')

ssn = input("Enter your Social Security Number (format: ddd-dd-dddd): ")

if ssn_pattern.match(ssn):

print("Valid SSN")

else:

print("Invalid SSN")

```

In the above code, we first import the `re` module to work with regular expressions.

We then define the regular expression pattern for the SSN format as `^\d{3}-\d{2}-\d{4}$`. This pattern matches any string that starts with three digits, followed by a hyphen, then two digits, another hyphen, and finally, four digits.

We then prompt the user to enter their SSN using the `input()` function. We then check if the entered SSN matches the pattern using the `match()` function of the regular expression object `ssn_pattern`.

If the SSN matches the pattern, we print "Valid SSN". Otherwise, we print "Invalid SSN".

Know more about SSN,

brainly.com/question/31778617

#SPJ4

Answer 2
Answer:

ssn = input("Enter a valid Social Security number: ")

dashes = 0

nums = 0

message = "Invalid SSN"

if len(ssn) == 11:

   for x in ssn:

       if x.isdigit():

           nums += 1

       elif x == "-":

           dashes += 1

if nums == 9 and dashes == 2:

   message = "Valid SSN"

print(message)

I wrote my code in python 3.8. I hope this helps!


Related Questions

Which technology is suitable to cover the whole city for internet?​
Given a String variable named sentence that has been initialized, write an expression whose value is the number of characters in the String referred to by sentence.
Express the worst case run time of these pseudo-code functions as summations. You do not need to simplify the summations. a) function(A[1...n] a linked-list of n integers) for int i from 1 to n find and remove the minimum integer in A endfor endfunction
Write an Enlistee class that keeps data attributes for the following pieces of information: • Enlistee name • Enlistee number Next, write a class named Private that is a subclass of the Enlistee class. The Private class should keep data attributes for the following information: • Platoon number (an integer, such as 1, 2, or 3) • Years of service (also an integer)
3. Problem 5. A digital computer has a memory unit with 24 bits per word. The instruction set consists of 150 different operations. All instructions have an operation code part (opcode) and an address part (allowing for only one address). Each instruction is stored in one word of memory. a. How many bits are needed for the opcode? b. How many bits are left for the address part of the instruction? c. What is the maximum allowable size for memory? d. What is the largest unsigned binary number that can be accommodated in one word of memory?

Definition of letter in communication skills

Answers

Answer:

Explanation:A letter is a written message conveyed from one person to another person through a medium. Letters can be formal and informal. Besides a means of communication and a store of information, letter writing has played a role in the reproduction of writing as an art throughout history.

Answer:

A letter is a written message conveyed from one person to another person through a medium. Letters can be formal and informal. Besides a means of communication and a store of information, letter writing has played a role in the reproduction of writing as an art throughout history.

  • Excellent written and verbal communication skills.
  • Confident, articulate, and professional speaking abilities (and experience)
  • Empathic listener and persuasive speaker.
  • Writing creative or factual.
  • Speaking in public, to groups, or via electronic media.
  • Excellent presentation and negotiation skills.

In cell B13, create a formula without a function using absolute references that subtracts the values of cells B5 andB7 from cell B6 and then multiples the result by cell B8. please help with excel!! I'm so lost

Answers

Answer:

The formula in Excel is:

=($B$6 - $B$5 - $B$7)* $B$8

Explanation:

Required

Use of absolute reference

To reference a cell using absolute reference, we have to include that $ sign. i.e. cell B5 will be written as: $B$5; B6 as $B$6; B7 as $B$7; and B8 as $B$8;

Having explained that, the formula in cell B13 is:

=($B$6 - $B$5 - $B$7)* $B$8

For additional security and to optimize the performance of critical machines on your organization’s network, it is crucial to:___________.

Answers

Answer:

Identify any program or services that you do not need.

Explanation:

As a network administrator, one of the preventive measures that could be adopted to complement your security system or architecture is to identify all the software applications or services that you do not need in an organization. This is because some of these programs might be a spyware, rootkit or compromised software which are used to gain unauthorized access to the network system. Also, you should identify the unused or unwanted programs or services in order to prevent redundancy and to optimize the performance of critical machines or processes in the organization's network.

Hence, for additional security and to optimize the performance of critical machines on your organization’s network, it is crucial to identify any programs or services that you don’t need.

Write statements that declare inFile to be an ifstream variable and outFile to be an ofstream variable.

Answers

Answer:

Following are the statement in the c++ language

ifstream inFile;  // declared a variable inFile

ofstream outFile;//declared a variable outFile

Explanation:

The  ifstream and ofstream  is the file stream object in the c++ Programming language .The ifstream file stream object is used for reading the contents from the file whereas the ofstream  file stream object is used for writting the contents into the file.

  • We can create the variable for the ifstream and ofstream These variable is used for reading and writing into the File.
  • Following are the syntax to create the ifstream variable and ofstream variable

        ifstream variablename;

        ofstream  variablename

Implement the RC4 stream cipher in C++. User should be able to enter any key that is 5 bytes to 32 bytes long. Be sure to discard the first 3072 bytes of the pseudo random numbers. THE KEY OR THE INPUT TEXT MUST NOT BE HARD CODED IN THE PROGRAM.

Answers

Answer:

Explanation:

#include <iostream>

#include <string>

#include<vector>

using namespace std;  

vector<int> permute(vector<int>, vector<int>);

string encrypt(vector<int>s1 , vector<int> t1, string p);

string decrypt(vector<int>s1, vector<int> t1, string p);

int main() {

  string plaintext = "cryptology";

  string plaintext2 = "RC4";

  vector<int> S(256);

  vector<int> T(256);

  int key[] = { 1,2,3,6 };

  int key2[] = { 5,7,8,9 };

  int tmp = 0;

  for (int i = 0; i < 256;i++) {

      S[i] = i;

      T[i] = key[( i % (sizeof(key)/sizeof(*key)) )];

  }

  S = permute(S, T);

  for (int i = 0; i < 256 ;i++) {

      cout << S[i] << " ";

      if ((i + 1) % 16 == 0)

          cout << endl;

  }

  cout << endl;

  string p = encrypt(S, T, plaintext);

  cout << "Message: " << plaintext << endl;

  cout << "Encrypted Message: " << " " << p << endl;

  cout << "Decrypted Message: " << decrypt(S, T, p) << endl << endl;

  tmp = 0;

  for (int i = 0; i < 256;i++) {

      S[i] = i;

      T[i] = key2[(i % (sizeof(key) / sizeof(*key)))];

  }

  S = permute(S, T);

  for (int i = 0; i < 256;i++) {

      cout << S[i] << " ";

      if ((i + 1) % 16 == 0)

          cout << endl;

  }  

  cout << endl;

  p = encrypt(S, T, plaintext2);

  cout << "Message: " << plaintext2 << endl;

  cout << "Encrypted Msg: " << p << endl;

  cout << "Decrypted Msg: "<<decrypt(S, T, p) << endl << endl;

  return 0;

}

string decrypt(vector<int>s1, vector<int> t1, string p) {

  int i = 0;

  int j = 0;

  int tmp = 0;

  int k = 0;

  int b;

  int c;

  int * plain = new int[p.length()];

  string plainT;

  for (int r = 0; r < p.length(); r++) {

      i = (i + 1) % 256;

      j = (j + s1[i]) % 256;

      b = s1[i];

      s1[i] = s1[j];

      s1[j] = b;

      tmp = (s1[i] + s1[j]) % 256;

      k = s1[tmp];

      c = ((int)p[r] ^ k);

      plain[r] = c;

      plainT += (char)plain[r];

  }

  return plainT;

}  

string encrypt(vector<int>s1, vector<int> t1, string p) {

  int i = 0;

  int j = 0;

  int tmp = 0;

  int k = 0;

  int b;

  int c;

  int * cipher = new int [p.length()];

  string cipherT;

  cout << "Keys Generated for plaintext: ";

  for (int r = 0; r < p.length(); r++) {

      i = (i + 1) % 256;

      j = (j + s1[i]) % 256;

      b = s1[i];

      s1[i] = s1[j];

      s1[j] = b;

      tmp = (s1[i] + s1[j]) % 256;

      k = s1[tmp];

      cout << k << " ";

      c = ((int)p[r] ^ k);

      cipher[r] = c;  

      cipherT += (char)cipher[r];

  }

  cout << endl;

  return cipherT;

}

vector<int> permute(vector<int> s1, vector<int> t1) {

  int j = 0;

  int tmp;

  for (int i = 0; i< 256; i++) {

      j = (j + s1[i] + t1[i]) % 256;

      tmp = s1[i];

      s1[i] = s1[j];

      s1[j] = tmp;

  }

  return s1;

}

In the early days of computer technology, which system was justified because data-processing personnel were in short supply, hardware and software were expensive, and only large organizations could afford computers

Answers

Answer:

Centralized Processing

Explanation:

Centralized processing was developed to process all of the data in a single computer, and since the first computers were stand-alone with all input and output devices in the same room, only the largest organizations could afford to use centralized processing.