Java Program For City Guide

class CityGuide
{
 public static void main(String args[])
 {
  char choice;
  System.out.println("Select your choice");
  System.out.println("M-->Madras");
  System.out.println("B-->Bombay");
  System.out.println("C-->culcutta");
  System.out.println("choice-->");
  System.out.flush(); //clears the output stream after writing the left over bytes (if any).
  
  try
  {
   switch (choice = (char) System.in.read())
   {
    case 'M' :
    case 'm': System.out.println("Madras");
        break;
    case 'B':
    case 'b': System.out.println("Bombay");
               break;
    case 'C':
    case 'c': System.out.println("Culcutta");
              break;
    default: System.out.println("Invalid choice (IC)");
   }
  }
  catch (Exception e)
  {
    System.out.println("i/o Error");
  }
 }
}
Bhanu Namikaze

Bhanu Namikaze is an Ethical Hacker, Security Analyst, Blogger, Web Developer and a Mechanical Engineer. He Enjoys writing articles, Blogging, Debugging Errors and Capture the Flags. Enjoy Learning; There is Nothing Like Absolute Defeat - Try and try until you Succeed.

No comments:

Post a Comment