• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 534
  • Last Modified:

Java - How To Make A Menu For Com Prompt?

Not looking for a massively complex menu, just wondering how to create one for the likes of command prompt.

Basically so that it displays the 4 - 5 options I have and allows the user to enter A, B, C, D, E etc to select that one that they want.

All help appreciated guys.
0
angus_young_acdc
Asked:
angus_young_acdc
  • 3
  • 2
1 Solution
 
venkateshwarrCommented:
I dont think there is any support for text based menu in Jave. you have to write it your self
0
 
suprapto45Commented:
Hi,

You can use System.in to accomplish it.

I try to send you some sample.

Regards
Dave
0
 
suprapto45Commented:
Hi,


package com.experts;

import java.io.*;

public class Echo {
    public static void main(String args[]) throws Exception{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

        String input = "";

        while(true){

            System.out.println("Press enter 1 for 'Say One' ");
                  System.out.println("Press enter 2 for 'Say Two' ");
                  System.out.println("Press enter 3 for Exit ");
                  System.out.print ("You enter : ");

            input = in.readLine();
      
                  if (Integer.parseInt(input) == 1)
                  {
                        System.out.println("Say One");
                  }
                  else if (Integer.parseInt(input) == 2)
                  {
                        System.out.println("Say Two");
                  }
                  else if (Integer.parseInt(input) == 3)
                  {
                        System.out.println("Thank you");
                        break;                        
                  }
                  else
                  {
                        System.out.println("Please choose 1 - 3 only");
                  }
        }

    }

}


Regards
Dave
0
 
venkateshwarrCommented:
I am sorry, I misread ur question..
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now