debugging techniques

debugging techniques

java program to accept the employee code from user and validate it according to the following logic. The first character of the employee code should be the letter 'E'. If it is any other letter, throw a user defined exception that displays an appropriate error message.

View Answers

June 15, 2012 at 5:15 PM

Here is an example that validates employee code. The given code accepts the code from the user and validate using regular expression. If the user starts the code with the capital letter E followed by other alphabets and numbers, then it will take otherwise it will show error message and allow the user to enter again.

import java.util.*;
class ValidateEmployee 
{
    public static boolean validateString(String st) {
                return st.matches("[E]+[a-zA-Z0-9]*");
        }



    public static void main(String[] args) 
    {
        Scanner input=new Scanner(System.in);
        System.out.print("Enter code: ");
        String code=input.next();
        while (validateString(code) != true) {
                        System.out.print("Invalid String!");
                        System.out.println();
                        System.out.print("Enter String: ");
                        code = input.nextLine();
                }
    }
}

Ads









Related Tutorials/Questions & Answers:
debugging techniques
debugging techniques  java program to accept the employee code from user and validate it according to the following logic. The first character of the employee code should be the letter 'E'. If it is any other letter, throw a user
ModuleNotFoundError: No module named 'django-debugging'
ModuleNotFoundError: No module named 'django-debugging'  Hi, My... named 'django-debugging' How to remove the ModuleNotFoundError: No module named 'django-debugging' error? Thanks   Hi, In your
Advertisements
What are data science techniques?
What are data science techniques?  Hi, I am beginner in Data Science... are data science techniques? Try to provide me good examples or tutorials links so that I can learn the topic "What are data science techniques?"
ModuleNotFoundError: No module named 'remote-debugging-path-chromium'
ModuleNotFoundError: No module named 'remote-debugging-path-chromium' ...: No module named 'remote-debugging-path-chromium' How to remove the ModuleNotFoundError: No module named 'remote-debugging-path-chromium' error
search and sort techniques in java
search and sort techniques in java  Hi i attened an interview recently... they asked to write all searching and sorting technique codes in java.. i said i would use collection frame work for it.. but they dosnt want me to use
RIAs Methods And Techniques
RIAs Methods And Techniques JavaScript It is the first major client side language technology that has the ability to run code and installed on several major of web clients. Earlier its uses were relatively limited but the development
a competitive study on cryptography techniques over block cipher
a competitive study on cryptography techniques over block cipher  i need "a competitive study on cryptography techniques over block cipher" project source code... plz reply to my post... for more information about this project
Business Analysis Techniques
There are many business analysis techniques that are quite useful in carrying out an effective and productive business analysis. Some of the important techniques for business analysis often used by business analysts are: PESTLE
Java code debugging
Top 20 SEO Techniques for Google Search Ranks
, some of the good old SEO techniques have never been so important. Once again.... Though in presenting top SEO techniques for Google search ranks we are most likely... tools and techniques. Here is our pick on top SEO techniques for Google search
Web 2.0 Characteristics,Web 2.0 Applications,Web 2.0 Conference,Web 2.0 Tools,Web 2.0 Technologies,Web 2.0 Techniques
usually feature a number of following techniques: Rich Internet application techniques, optionally Ajaxbased Cascading Style Sheet, CSS Semantically valid
Search Engine Optimization (SEO) Techniques
Search Engine Optimization (SEO) Techniques Search engine optimization... include techniques which are recommended as good design techniques. While black hat techniques are those techniques which are not approved by search
FLABot
of the existing techniques to deal with debugging operate at the level of source code...; FLABot is a fault-localization and debugging tool for Eclipse plug-ins, which...) and supported by Intel Corporation. Project Description Debugging is one of the most
Tips for Successful Outsourcing,Useful Tips of Successful Outsourcing,Tips and Techniques for Successful Outsourcing
SmartInspect
logging tool for debugging and monitoring your projects and applications... SmartInspect is the perfect solution for debugging web applications, distributed
Method
Method       In this section, we will explore the concept of method in the reference of object oriented programming techniques. As we earlier described in the topic class, a class have
Method in Java
Method in Java       In this section, we will explore the concept of method in the reference of object oriented programming techniques. As we earlier described in the topic class
Printing a Stack Trace to the Server Console
the error instead of debugging jsp pages. By  the stack trace, you will know... getMessage() method of the exception to print errors during debugging process
ModelOps Tutorial
In this section we are going to learn fast growing ModelOps techniques which are used... to be trending technologies in 2021 and Data Scientist must learn the techniques... are going to learn ModelOps techniques and see how it can be used
Guest Posting Tutorial - Getting Started with Guest Posting
techniques. What are the steps of guest posting? Now we will see the steps of creating
Class
techniques. A class defines the properties of  objects and methods used... concept is employed in the object oriented techniques to create the objects through
iPhone Application Store Submission and Acceptance Process
Development, App Testing and Debugging, Application Listing on the online Apple iPhone
Google Penguin 2.0 Update
cashing on Black-Hat SEO techniques and SEO tricks but Google is day-by-day... SEO techniques. 2.3% of English searches have been affected by this update
How to Protect against the Penguin Update
techniques and NOT Black-Hat or Grey-Hat SEO techniques. It has been proven time
How to Recover from Google Penguin Update and Get the Ranking Back
Just after May 22 2013, all websites involved in Black-Hat and Grey-Hat SEO techniques took a huge dive in their ranking. Poorly indexed websites, spammy... reason. They were targeting search engine and planned their SEO techniques around
Google Penguin Algorithm update issues and How to Recover
and Grey-Hat SEO techniques have been hit harshly. SEO must make sure... website. SEO used paid links techniques to target specific keywords, generate
JSlice
JSlice What is dynamic slicing? Dynamic slicing is a technique for program debugging and understanding. Given a program P, the programmer provides a slicing criterion of the form (I, L, V), where I is a program input, L
Cell Phone Locator System
of techniques that let a party or a person to know about the location coordinates... at the location of the nearby cell phone. The accuracy mobile tracking techniques... techniques. The technologically advanced system of tracking the Phone only
Struts2 Application in Eclipse: Running the application in Eclipse IDE
the applications which is very powerful and provides many features for debugging
How to Recover from Google Penguin 2.0 Updates
SEO and Grey-Hat SEO techniques, all have taken a big blow after the launch... for a long term White-Hat SEO techniques are the only way. At first "no follow" all.... But with the release of Penguin 2.0 , Google is making sure that such techniques does
Pros and Cons of Gray Hat SEO
. According to the acceptance level and ethical shortcoming of techniques geared towards search engine results there are three distinct types of SEO techniques, respectively as Black Hat SEO, Gray Hat SEO and White Hat SEO techniques

Ads