I need help making a java code. 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 should check if the input is valid. If the program isn't valid I need to provide 1 of 3 feedback.  1"You entered an invalid social security number." 20%" 2 "Can't you follow directions? 40%" 3. "You are not very smart are you?" 40% I need 1 to come 20% of the time, and 2 and 3 40% I need random number gen used to select the response. I keep getting an error saying java: reached end of file while parsing

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter6: Looping
Section: Chapter Questions
Problem 2PE
icon
Related questions
Question

I need help making a java code. 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 should check if the input is valid. If the program isn't valid I need to provide 1 of 3 feedback. 

1"You entered an invalid social security number." 20%"

2 "Can't you follow directions? 40%"

3. "You are not very smart are you?" 40%

I need 1 to come 20% of the time, and 2 and 3 40% I need random number gen used to select the response.

I keep getting an error saying java: reached end of file while parsing

import java.util.Scanner;

public class security_number

{

public static void main (String [] args)

{

Scanner in= new Scanner (System.in);

System.out.print("Enter social security number:");

String s= in.nextLine();

boolean isValid = (s.length==11) && ( Character.isDigit(s.charAt(0))) && (Character.isDigit(s.charAt(1))) && (Character.isDigit(s.charAt(2))) &&  (s.charAt(3)== '-' ) && (Character.isDigit(s.charAt(4))) && (Character.isDigit(s.charAt(5))) && (s.ChatAt(6)=='-') && (Character.isDigit(s.charAt(7))) && (Character.isDigit(s.charAt(8))) && (Character.isDigit(s.charAt(9))) &&

(Character.isDigit(s.charAt(10)));

if(isValid)

{

System.out.println("You entered valid social security number");

}

else

{

System.out.println("You entered an invalid social security number");

}

}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT