Java Menu

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Jun 2009
Posts: 142
Reputation: whiteyoh is an unknown quantity at this point 
Solved Threads: 2
whiteyoh whiteyoh is offline Offline
Junior Poster

Java Menu

 
0
  #1
Nov 2nd, 2009
Hi All,

Hoping you can help with the following.

The psuedo code is:

1. Menu is displayed
2. User inputs a selection
3. That item is ran
4. on completion, the user is returned to 1 above.

the code i have so far is as follows, but its still exiting the program.
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5.  
  6. package week7;
  7. //import java.io.*;
  8. //import java.io.IOException;
  9. import java.util.Scanner;
  10. /**
  11.  *
  12.  * @author Administrator
  13.  */
  14. public class whileDoTest {
  15.  
  16. public static void main (String[]arguments)
  17. {
  18.  
  19.  
  20. System.out.println("Please make your selection");
  21. System.out.println("");
  22. System.out.println("(1) - New book : (2) - New user : (3) - New Load");
  23. Scanner scan = new Scanner(System.in);
  24. int menuSelect = scan.nextInt();
  25. switch (menuSelect)
  26. {
  27. case 1:
  28. menuSelect = 1;
  29. System.out.println("Selection 1");
  30. System.out.println("(1) - Main Menu");
  31. menuSelect=0;
  32. break;
  33.  
  34. case 2:
  35. menuSelect = 2;
  36. System.out.println("Selection 2");
  37. break;
  38.  
  39. case 3:
  40. System.out.println("Selection 3");
  41. break;
  42. }
  43. // menuSelect = 0;
  44.  
  45. while (menuSelect > 0 );
  46. }
  47.  
  48. }
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 142
Reputation: whiteyoh is an unknown quantity at this point 
Solved Threads: 2
whiteyoh whiteyoh is offline Offline
Junior Poster
 
0
  #2
Nov 2nd, 2009
just noticed a really stupid error. will post corrected code
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 142
Reputation: whiteyoh is an unknown quantity at this point 
Solved Threads: 2
whiteyoh whiteyoh is offline Offline
Junior Poster
 
0
  #3
Nov 2nd, 2009
here it is corrected, but ive made it worse, but hope you can get an idea what im trying to achieve

  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5.  
  6. package week7;
  7. //import java.io.*;
  8. //import java.io.IOException;
  9. import java.util.Scanner;
  10. /**
  11.  *
  12.  * @author Administrator
  13.  */
  14. public class whileDoTest {
  15.  
  16. public static void main (String[]arguments)
  17. {
  18.  
  19.  
  20. System.out.println("Please make your selection");
  21. System.out.println("");
  22. System.out.println("(1) - New book : (2) - New user : (3) - New Load");
  23. Scanner scan = new Scanner(System.in);
  24. int menuSelect = scan.nextInt();
  25. switch (menuSelect)
  26. {
  27. case 1:
  28. if(menuSelect ==1) {
  29. System.out.println("Selection 1");
  30. System.out.println("(1) - Main Menu");
  31. menuSelect=0;
  32. break;
  33. }
  34.  
  35. if (menuSelect ==2){
  36. case 2:
  37. menuSelect = 2;
  38. System.out.println("Selection 2");
  39. break;
  40. }
  41. case 3:
  42. System.out.println("Selection 3");
  43. break;
  44. }
  45. // menuSelect = 0;
  46.  
  47. while (menuSelect > 0 );
  48. }
  49.  
  50. }
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 142
Reputation: whiteyoh is an unknown quantity at this point 
Solved Threads: 2
whiteyoh whiteyoh is offline Offline
Junior Poster
 
0
  #4
Nov 2nd, 2009
im going to close and re-open as i made a stupid mistake on the first post
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum


Views: 238 | Replies: 3
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC