Question

Write a program which will get the personal names from the user and store them in a list (created using ArrayList) called personalNames. If there is any other character besides “a-z” or “A-Z” in a record, those should be flagged as ill-defined data. Because of the stated reasons above, instead of trying to fix the error in personal names, we want to remove this ill-defined data from the original list and move it to another list called errorProneNames. In other words, error involving records should be saved in a separate array. At the end your solution should print out the personalNames and errorProneNames lists separately.

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

import java.util.*;

public class PersonalNameList {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);

ArrayList<String> personalNames = new ArrayList<String>();
ArrayList<String> errorProneNames = new ArrayList<String>();

for(int i = 0; i < personalNames.size(); i++) {

for(int j = 0; j < personalNames.get(i).length(); j++) {

if((personalNames.get(i) >= 'A' && personalNames.get(i) <= 'Z') || (personalNames.get(i) >= 'a' && personalNames.get(i) <= 'z')) {...

This is only a preview of the solution. Please use the purchase button to see the entire solution

Related Homework Solutions

Acme Corporation Problems Using Java
Homework Solution
$30.00
Java
Programming
Computer Science
Acme Corporation
Employees
Hourly Rate
Salaries
Algorithms
Volunteers
Classes
Inheritance
Source Files
Diagrams
Java Programming Problems: Expression Trees and AVL Trees
Homework Solution
$50.00
Java
Programming
Computer Science
Expression Trees
AVL Trees
Algorithms
Input
Output
Recursive Functions
Strings
Variables
Statements
Loops
Methods
Expressions
Objects
Classes
Operators
Nodes
Numbers
Programming Problems
Homework Solution
$40.00
Computer Science
Programming
Applications
Instances
Variables
Personal Identification Number
Boolean
Functions
Strings
Parameters
Arrays
Students
Java Programming Problems
Homework Solution
$75.00
Computer Science
Java Programming
Integers
Strings
Algorithms
Codes
Constructor
Sensors
Parameters
Scaling
Critical Evaluation
Compile-Time Errors
Java Programming Problems
Homework Solution
$48.00
Computer Science
Java Programming
Multiple Choice Questions
Arrays
Classes
Constructors
Statements
Variables
Strings
Instances
Functions
Java Programming Problems
Homework Solution
$50.00
Computer Science
Java Programming
Algorithms
Loops
Data
Graphic Dialog Box
Objects
Classes
Statements
Variables
Inventory
Input
Output
Verification
File Management
Items
Get help from a qualified tutor
Live Chats