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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 18:30, bankzdown
The method of presentation refers to the planning process for the presentation. the information chosen for the presentation. how the presentation topic will be introduced. how the presentation will be delivered.
Answers: 1
image
Computers and Technology, 22.06.2019 11:00, najerajulio
What is the foundation for proper monitoring, load balancing and routing in distributed systems
Answers: 3
image
Computers and Technology, 22.06.2019 13:30, 21megoplin
In which phase does software coding and testing happen in the spiral model? the spiral model does not have a separate testing phase. both, software coding and testing occurs during the phase.
Answers: 3
image
Computers and Technology, 24.06.2019 01:00, kkruvc
Mastercard managers are motivated to increase (1) the number of individuals who have and use a mastercard credit card, (2) the number of banks and other clents who issue mastercards to customers and/or employees, and (3) the number of locations that accept mastercard payments. discuss how mastercard could use its data warehouse to it expand each of these customer bases.
Answers: 3
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 in other subjects: