Input program using switch

/* Yesterday I created a program that accepts user input

    and returns result depending on the initial you entered*/

import java.io.*;

public class PickEmployee{

public static void main(String[]args)throws IOException{

    BufferedReader james=new

      BufferedReader(new InputStreamReader(System.in));

    char Z;

     System.out.println(“Please enter a letter: “);

      Z=(char)System.in.read();

      switch(Z){

        case ‘a’:

          System.out.println(“Adam”);

           break;

         case ‘r’:

           System.out.println(“Romeo”);

            break;

          case ‘s’:

            System.out.println(“Sam”);

             break;

           default:

              System.out.println(“Employee does not exist!”);

       }

 }

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: