

IF YOU HAVE ANY DOUBTS COMMENT BELOW I WILL BE THERE TO HELP YOU
RATE THUMBSUP PLEASE
ANSWER:
CODE:
import java.util.*;
class Validation{
public static void main(String args[]){
Scanner in = new Scanner(System.in);
String name, fname, lname, mname, address, st_address, city, state, country, phone;
while(true){
System.out.print("Enter name: ");
name = in.nextLine();
StringTokenizer st = new StringTokenizer(name, " ");
if(st.countTokens()<2)
System.out.println("Invalid name, must be Firstname Middlename(optional) Lastname");
else{
boolean valid = true;
while(st.hasMoreTokens()){
if(!isValidName(st.nextToken())){
System.out.println("Invalid name, Firstname, Middlename, Lastname should start with an uppercase letter followed by lower case letters");
valid = false;
}
}
if(valid)
break;
}
}
while(true){
System.out.print("Enter address: ");
address = in.nextLine();
StringTokenizer st = new StringTokenizer(address, ",");
if(st.countTokens()<4)
System.out.println("Invalid name, must be Firstname Middlename(optional) Lastname");
else{
boolean valid = true;
int i=0;
while(st.hasMoreTokens()){
if(i==0){
st.nextToken();
i++;
continue;
}
if(!isValidAddress(st.nextToken())){
System.out.println("Invalid address, Street address, city, state (or province), country should start with an uppercase letter followed by lower case letters");
valid = false;
break;
}
}
if(valid)
break;
}
}
while(true){
System.out.print("Enter Phone number: ");
phone = in.nextLine();
if(isValidPhone(phone))
break;
System.out.println("Invalid Phone number, should begin with area code in parenthesis, followed by a space, three digits, a hyphen, and four digits.");
}
System.out.println("\nEntered Details are: ");
System.out.println(name+"\n"+address+"\n"+phone);
}
public static boolean isValidName(String str){
if(str.length()==0)
return false;
if(str.charAt(0)<'A' || str.charAt(0)>'Z')
return false;
for(int i=1; i<str.length(); i++){
if((str.charAt(i)<'a' || str.charAt(i)>'z') && str.charAt(i)!=' ' && str.charAt(i)!='.')
return false;
}
return true;
}
public static boolean isValidAddress(String str){
str = str.trim();
if(str.length()==0)
return false;
if(str.charAt(0)<'A' || str.charAt(0)>'Z')
return false;
for(int i=1; i<str.length(); i++){
if((str.charAt(i)<'a' || str.charAt(i)>'z') && (str.charAt(i)<'A' || str.charAt(i)>'Z') && str.charAt(i)!=' ' && str.charAt(i)!='.')
return false;
}
return true;
}
public static boolean isValidPhone(String mobile){
if(mobile.length()!=14)
return false;
if(mobile.charAt(0)=='(' && mobile.charAt(4)==')' && mobile.charAt(5)==' ' && mobile.charAt(9)=='-'){
if(Integer.parseInt(mobile.substring(1, 3))!=0 && Integer.parseInt(mobile.substring(6, 8))!=0 && Integer.parseInt(mobile.substring(10, 13))!=0)
return true;
}
return false;
}
}
RATE THUMBSUP PLEASE
THANKS
Your task for this project is to write a parser for a customer form. You need to develop a Java a...
Write a java project that reads a sequence of up to 25 pairs of names and postal (ZIP) codes, street address, city, state, and 10-digit phone number for individuals. Store the data in an object designed to store a first name (string), last name (string), and postal code (integer), street address (string), city( string), state (string), and 10-digit phone number (long integer, contains area code and does not include special characters such as '(', ')', or '-' . Assume each...
Write a java project that reads a sequence of up to 25 pairs of names and postal (ZIP) codes for individuals (sample input data is attached). Store the data in an object designed to store a first name (string), last name (string), and postal code (integer). Assume each line of input will contain two strings followed by an integer value, each separated by a tab character. Then, after the input has been read in, print the list in an appropriate...
in a java application need to create an application which prompts the user numerator and denominator values then show the result of the division. The application will use exception handling to verify the user has entered valid input and will continue to prompt the user for input as long as the value they enter is invalid. Once the user has entered valid numerator and denominator values, the result is shown and the application exits. had some issues when I entered letters instead of...
Write a Java program that checks the properness of a given variable name. More specifically, your program should specify whether a user-entered variable name is illegal (no spaces allowed, must begin with a letter) legal, but uses poor style (should only use letters or digits) good You don’t need to check for an uppercase letter for the first letter in the second word, third word, etc. Sample session: This program checks the properness of a proposed Java variable name. Enter...
hello. i need help with number 2
ONLY
1. Use if statements to write a Java program that inputs a single letter and prints out the corresponding digit on the telephone. The letters and digits on a telephone are grouped this way 2=ABC 3 = DEF 4 GHI 5 JKL 6 - MNO 7 - PRS 8 - TUV 9-WXY No digit corresponds to either Qor Z. For these 2 letters your program should print a message indicating that they...
In C++, You are given a file of customer data with records in the following format : account number, last name, first name, middle name. Write a program to convert the input data and display it to the monitor in the following format : Accout Name Logon ID Initial Pswd 21-88282712-B Keith S. Adams ADAM21 Adam88282 08-36847734-A John R. Sturm STUR08 Stur36847 etc. Notes : 1) The account number on the input is 10 digits 2) The names on...
Need Solution in JAVA Up until this deliverable, you should have finished your design (it should include the CFG in JAVA) and be ready to start the implementation of your toy compiler (or parser). In this project deliverable, you are required to submit all artifacts resulted from your efforts devoted to the course project. Specifically, you should Summarize your design of the toy compiler (or parser), including but not limited to keywords, variables, operators, statements, etc. (recall the in-class demo...
Programming Project 3 See Dropbox for due date Project Outcomes: Develop a Java program that uses: Exception handling File Processing(text) Regular Expressions Prep Readings: Absolute Java, chapters 1 - 9 and Regular Expression in Java Project Overview: Create a Java program that allows a user to pick a cell phone and cell phone package and shows the cost. Inthis program the design is left up to the programmer however good object oriented design is required. Project Requirements Develop a text...
Write a (Windows) two-class application that creates a customer code to be placed on a mailing label for a magazine. Allow the user to input their full name with the first name entered first. Prompt them to separate their first and last name with space. Ask for their birthdate in the format of mm/dd/ yyyy. Ask for the month (number) they purchased a subscription and ask for their zip code. Your mailing label should contain the last name, followed by...
I have to use java programs using netbeans. this
course is introduction to java programming so i have to write it in
a simple way using till chapter 6 (arrays) you can use (loops ,
methods , arrays)
You will implement a menu-based system for Hangman Game. Hangman is a popular game that allows one player to choose a word and another player to guess it one letter at a time. Implement your system to perform the following tasks: Design...