Write code to generate a random character between 48 and 122 (inclusive).

Learning Goal: I’m working on a java multi-part question and need an explanation and answer to help me learn.

ASSIGNMENT NO. 1 ( LAB#5 )

LAB 5 DUE 10/31

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:

  • The total number of characters in the string (better be 100)
  • The total number of digits
  • The total number of letters
  • The total number of upper-case letters
  • The total number of lower-case letters
  • The total number of characters not a letter or digit

————————————————————————————————————————————————————————————————-

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

ASSIGNMENT NO. 2 ( HW#5 )

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:

 

  • Any record whose status code is neither D or F should be written to the screen indicating the error. The next record should be read in.
  • If the status code is D or F, validate the salary that it contains only digits and one decimal point 3 positions from the right (indicating cents).
    • If the salary is invalid, print the entire record to the screen, indicating the error (char at position x is not a digit or period is missing or period is in the wrong position).
    • If the salary is valid, convert it to a double.
    • If the status code is D, compute the bonus (double) as 12.5% of salary and 18% if the status code is F.
  • Separate the cityState into two individual Strings named city and state. Use the position of the comma to help extract the city portion before the comma and the state after the comma (use indexOf to find the comma and substring to extract the two parts)
  • Each record that has a status of D should be written to a file named strOutputD and those record with status of F should be written to a file named strOutputF.
    • For both files, each record printed should include firstName, lastName, status, salary, bonus, city and state (without the comma)
  • When all records have been read in, print to the screen the number of D, F and incorrect records processed.
  • Submit your code, the output on the screen and the output in the two files.

SPECIAL INSTRUCTION : 2 SEPARATE SPECIFIC FILE ACCORDING TO THE ASSIGNMENT NAME AND HW OR LAB NUMBER. MAKE 3 DIFFERENT FILE FOR 2 DIFFERENT JAVA PROGRAMMING ASSIGNMENT I EXPLAINED. YOU HAVE TO SHOW PICTURE OF YOUR CODING PROGRAM . YOU HAVE TO ADD THE CODING PICTURES. Write a complete Java program, including comments in both the main program and in each method. YOU HAVE TO USE ECLIPSE JAVA IDE

EXPLAIN ALL THE ANSWERS AND I need the whole assignment programming code in google docs. Just copy the code and paste it on google docs and full program from your Java IDE. I need all the answers and all the java code clearly in Java IDE and Google DOCS and I need the answer of the all the questions from the assignment fully cleared. The code have to be perfectly run without any error. And explain everything with answers.”!!!

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more
error: Content is protected !!