Question
Write a Java program that prompts the user to enter: - a two character string containing only lowercase characters in the range az - a
Write a Java program that prompts the user to enter:
- a two character string containing only lowercase characters in the range az
- a three character string consisting of a lowercase letter in the range az, followed by two digits (each in the range of 0 to 9, inclusive)
The program must use validation, and prompt the user to retry if either of the entries is invalid. When both of the inputs are valid, the program should output to a file in CSV format as follows:
- write each of the user inputs on line 1 of the file
- write LP as the last value on line 1 of the file
- write, on line 2 of the file, the numeric equivalent of each individual letter from the first line, separated by commas.
- Assume a=A=1, b=B=2, ..., z=Z=26.
- write, on line 3 of the file, the sum of the values of line 2
The file name should be of the format YYYYMMDDIN.txt where:
- YYYYMMDD is the date the program is run (in year month day format)
- IN are the initials of your name
- .txt is the filename extension
- Example filename: 20220112LP.txt
Example program execution (user entry is shown in green italics): Please enter a string of two az characters: ac
Please enter a string of three characters (az followed by two digits): k12 E
xample file contents (with comma-separated values):
ac,k12,LP
1,3,11,3,18
The sum of the values in the second row is: 36
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started