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
Naddika [18.5K]
1 year ago
4

Write a program that prompts the user to enter a social security number in the format ddd-dd-dddd, where d is a digit. your prog

ram should check whether the input is valid.
Computers and Technology
1 answer:
stich3 [128]1 year ago
7 0

A program written by using Java that prompts an end user to enter a Social Security Number in the format "ddd-dd-dddd" is as follows:

  1. import java.util.Scanner;
  2. public class CheckSocialSecurityNumber_09_22 {
  3.    public static void main(String[ ] args) {
  4.        Scanner input = new Scanner(System.in);
  5.        System.out.print("Enter a SSN: ");
  6. //Creates Social Security Number (SSN) variable
  7. boolean isValid = ssn.length() == 11 &&
  8.               ssn.charAt(0) <= '9' && ssn.charAt(0) >= '0' &&
  9.    Character.isDigit(ssn.charAt(1)) && Character.isDigit(ssn.charAt(2)) &&
  10. ssn.charAt(3) == '-' && Character.isDigit(ssn.charAt(4)) &&
  11. Character.isDigit(ssn.charAt(5)) && ssn.charAt(6) == '-' &&
  12. Character.isDigit(ssn.charAt(7)) && Character.isDigit(ssn.charAt(8)) &&
  13. Character.isDigit(ssn.charAt(9)) && Character.isDigit(ssn.charAt(10));
  14. //Creates if-else statement to notify user whether the input (Social Security Number) is valid.
  15.     if (isValid)
  16.          System.out.println(ssn + " is a valid Social Security Number");
  17.     else
  18.          System.out.println(ssn + " is an invalid Social Security Number");
  19.      }
  20. }

<h3>What is JavaScript</h3>

JavaScript can be defined as an object-oriented computer programming language that is typically designed and developed for creating interactive effects within a software application such as web browsers.

<h3>What is an if-else statement?</h3>

An if-else statement can be defined as a conditional statement that is written by a computer programmer to handle decisions by running a different set of statements, depending on whether an expression is either true or false.

<u>Note:</u> The indentation may change due to Brainly's text editor.

Read more on JavaScript here: brainly.com/question/13266367

#SPJ1

You might be interested in
Declare a char array named line suitable for storing C-strings as large as 50 characters, and write a statement that reads in th
zlopas [31]

Answer:

char line[50];

cin.get(line,50);

Explanation:

The "char" data type stores character data in a fixed-length field.

3 0
3 years ago
Which of the following is NOT shown on a PERT chart? (Points : 2) Scheduled start date
Reptile [31]

Answer:

Estimated Duration

Explanation:

A PERT Chart is a tool in Project Management that gives a graphical portrayal of an undertaking's timetable. The Program Evaluation Review Technique abbreviated as PERT separates the individual assignments of a venture for investigation.  

The most widely recognized components utilized in a PERT chart are:  

  • Span time.  
  • Activity
  • Early finish time.  
  • Early Ending time
  • Late initiation time.  
  • Late completion time.  
  • Critical path
  • Slack.  

It does not include the Estimated span of time.

4 0
3 years ago
How to format each dictionary item as a text string in the input file. How to covert each input string into a dictionary item. H
Jet001 [13]

Answer:

- To get the items of a dictionary and print them as a string, use the items() method to unpack the keys and values in a for and print or write them into a file.

for key, value in mydict.items():

   print(f"{key}, {value}")

- To convert string from user input into dictionary;

   mystring = input().split(" ")  #assuming the words are separated by a space.

   from word in mystring:

       mydict[word] = mydict.get(word, 0) + 1

This would use the words in the string as the keys of the dictionary and the count of each word as the respective values.

Explanation:

A dictionary is a data structure in python used to store data in key-value pairs. The items are enclosed in curly braces and can be accessed with the key in dot or bracket notation.

7 0
3 years ago
Write an expression in Boolean algebra that evaluates to 1 when an odd number of bits of the number is 1 and 0 otherwise
Leokris [45]

α∨1=1 is an example of boolean algebra with result equal to 1.

<h3>What is boolean algebra?</h3>

Are algebraic structures that "capture the essential properties" of logical and set operators, or provide a structure for dealing with "statements".

With this information, we can conclude that The purpose of Boolean algebra is to describe signal processing, in the form of an algebraic expression.

Learn more about Boolean algebra in brainly.com/question/2467366

3 0
3 years ago
Give a recursive (or non-recursive) algorithm to compute the product of two positive integers, m and n, using only addition and
LiRa [457]

Answer:

Multiply(m,n)

1. Initialize product=0.

2. for i=1 to n

3.      product = product +m.

4. Output product.

Explanation:

Here we take the variable "product" to store the result m×n. And in this algorithm we find m×n by adding m, n times.

6 0
4 years ago
Other questions:
  • which resource do programmers sometimes have to refer to and use during planning the logical steps of the solution
    15·2 answers
  • A small company has developed a specialized software product that it configures specially for each customer. New customers usual
    14·1 answer
  • what important technology has done the most to allow small businesses a change to compete with larger international companies?
    5·1 answer
  • Kak cheat clans royale
    15·1 answer
  • Alice is an investor who has created a device controlled by an app that will water plants automatically. Alice has no experience
    9·1 answer
  • How to build a 5*32 decoder by using 3*8 and 2*4 decoders? (digital design)
    15·1 answer
  • Ports that are generally used to establish outbound connections are known as ___ ports.
    14·1 answer
  • ⦁ ¿Cuáles son los recursos naturales que se utilizan en tu comunidad para generar energía eléctrica?
    14·1 answer
  • Q.2 (A)
    5·1 answer
  • Select the word or phrase from the drop-down menu to complete each sentence. File names consist of a ______ and a file extension
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!