subject

Write a program that prompts the user to enter a social security number in the format ddd-dd-, where d is a digit. your program should check whether the input is valid.

hint: use chatat() and isdigit() methods.

ex.

input: 111-11-

output: valid ssn



input: 11-11-

output: invalid ssn

i know that i can solve this problem by looping through the characters of the string in the ssn but i want to make the code i wrote beneath work. i am having a problem on my second to last if- statement. in that statement it says that all of my variables d1-d9 "cannot be resolved to variable." i initially thought that this might be a problem with scope of my variables but i dont belive it is. why am i getting an error and what can i do to make this code work

import java. util. scanner;

public class checkssn {

public static void main(string [] args) {

scanner kbd_in = new scanner(system. in);

system. out. print(" enter your social security numer in the format ddd-dd-: ");

string social = kbd_in.();

system. out. println(" you have entered: "+ social);

kbd_in. close();

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 13:00
Why the bear has a slunky tail determine the meaning of the word slunk in the story
Answers: 1
question
Computers and Technology, 22.06.2019 15:20
This os integrated the processing power of windows nt with the easy-to-use gui of windows 98. windows 2000 windows 3.11 windows for workgroups windowa millennium edition
Answers: 1
question
Computers and Technology, 22.06.2019 19:00
Which parts of a presentation should be the most general? a. introduction and conclusion b. introduction and outline c. outline and conclusion d. outline and body
Answers: 1
question
Computers and Technology, 22.06.2019 21:50
Given int variables k and total that have already been declared, use a while loop to compute the sum of the squares of the first 50 counting numbers, and store this value in total. thus your code should put 11 + 22 + 33 + + 4949 + 50*50 into total. use no variables other than k and total.
Answers: 2
You know the right answer?
Write a program that prompts the user to enter a social security number in the format ddd-dd-, where...
Questions
question
Mathematics, 27.07.2019 07:40
question
Spanish, 27.07.2019 07:40
question
Social Studies, 27.07.2019 07:40
Questions on the website: 13722361