A. Write code to generate a random character between 48 and 122 (inclusive). You can do this by first generating an integer value between 48 and 122 and then cast it as a char. Do this in a loop 100 times, concatenating each character to a String as each character is generated. When the loop completes, the string will contain 100 characters. Print the string of 100 characters.
Remember that to generate a random number between a start and end value, the formula is:
(int)(start + Math.random()*(end-start+1))
Loop through the string you just created, character by character using charAt(i), to count and print the following:
B. Write a program that prompts the user to enter an enhanced Social Security number as a string in the format DDD-DD-DDDX where D is a digit from 0 to 9. The rightmost character, X, is legal if it’s between 0 and 9 or between A to Z.
The program should check whether the input is valid and in the correct format. There’s a dash after the first 3 digits and after the second group of 2 digits.
If an input is invalid, print the input and the position in the string (starting from position 0) where the error occurred.
If the input is valid, print a message that the Social Security number is valid.
Continue to ask for the next Social Security number but stop when a string of length 1 is entered.
Test cases
ABC
123-A8-1234
12-345-6789
12345-6789
123-45-678A
123-45-678AB
A
Homework 5 CISC 1115 TR11
Your Java program will be reading input from a file name strInput.txt. Each record contains
String firstname
String lastName
String strSalary (which will be converted to a double if it’s valid – see below)
char status
String cityState (city and state and combine together but separated by a comma)
Sample input:
Ira Rudowsky 87654.32 F Brooklyn,NY
Jane Doe 987609.87 F NY,NY
Mickey Mantle 345678.30 D Orlando,FL
Fran Young 10456.82 G Boston,MA
Richard Clark 67890.32 D Washington,DC
Jack Smith 23489A.82 D Houston,TX
Serena Williams 1295609.87 D Denver,CO
Read from the file one record at a time and process as follows: