Student

Currently I am a Computer Science major graduating in May 2016. I attend California State University, Long Beach.

Developer

I'm a front-end developer. I develop websites, mobile applications, desktop applications, and web applications.

Designer

I'm a web designer and a graphic designer with use of wordpress and blogger for web design and photoshop creative suite 5 for graphic design.

Business

Currently run a freelance business named Bell's Branding, Inc. writing websites and apps for new businesses and individuals.

Projects

Java menu program

I've been using this throughout the semester as it's very helpful giving the user options to choose between various tasks as well as return back to the original menu. In this program I've chosen two options the user can choose from and if it wants to exit the program the user chooses option 3. I've left the options as well as the cases empty as this is only an example of the menu.
import java.io.IOException;
import java.util.*;

/**
 *
 * @author Erin Bell
 * Example1: Implement a program with the options to do various tasks from the user.
 *
 */

public class menu
{

    /**
     * This function displays the menu for the user to choose an option from
     */
    public void Menu()
    {
    System.out.println("\nMenu: ");
    System.out.println("______________________");
        System.out.println("Option 1: Select 1 ");
        System.out.println("Option 2: Select 2");
        System.out.println("Option 3: Quit program");
    }
  
public menu() throws IOException
      {
           //Accepts user input

           //calls the menu method
    
           //Initializes the run variable making the program loop until the user terminates the program
        Boolean run=true;
    
        
           while(run) 
           {
        Menu();
            switch (new Scanner(System.in).nextInt())
        
            {
                case 1:
                System.out.println("Option 1 Selected");
                System.out.println("Do something");  
              
               break;
                case 2:
                System.out.println("Option 2 selected");
                System.out.println("Do something");
                  
               break;
                case 3:
               System.out.println("Program terminated");
               //Terminates user input
               run=false;
              break;
             //default case if one of the options selected were not allowed
           default:
               System.out.println("Not one of the options 1-3");
               System.out.println("Program terminated.");
             break;
            }
         }
       }
  
      /**
       * Main method
       * @param args
     * @throws IOException
       */

       public static void main(String[] args) throws IOException
       {
           //Calls the constructor
           new menu();
      
       }
}

No comments:

Post a Comment

Available Apps

Powered by Blogger.