Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners how to return to main menu after adding all the info.

Have Programming Question? Ask it here!
 
 
 


Alex
how to return to main menu after adding all the info.
1 Answer(s)      4 years and 11 months ago
Posted in : Java Beginners



Advertisement
View Answers

October 6, 2009 at 3:25 PM


Hi Friend,

Try the following code:

import java.io.*;
import java.util.*;

class Student{
public int id;
public String name;

public Student(){}
public Student(int id, String name) {
super();
this.id = id;
this.name = name;
}
public int getId() {
return id;
}
public String getName() {
return name;
}
}
public class RegistrationSystem {

public static void main(String[] args) throws Exception {
List<Student> list = new ArrayList<Student>();
list.add(new Student(1, "A"));
list.add(new Student(2, "B"));
list.add(new Student(3, "C"));
list.add(new Student(4, "D"));

Scanner scan = new Scanner(System.in);
int menu = 0;
System.out.println("School Registration System Main Menu");
System.out.println();
System.out.println("1. Add a student");
System.out.println("2. Remove a student");
System.out.println("3. Display student list");

System.out.print("Please enter your choice: ");
menu = scan.nextInt();
System.out.println();

switch(menu) {
case 1:
System.out.print("Enter student ID: ");
int ID = scan.nextInt();
System.out.print("Enter your name: ");
String name= scan.next();
list.add(new Student(ID,name));
for (Student s : list){
System.out.println(s.getId()+" " +s.getName());
}
case 2:
System.out.print("Enter Student id to remove the student from list: ");
int id = scan.nextInt();
int i=id-1;
list.remove(i);
case 3:
System.out.println("Id Name");
for (Student s : list){
System.out.println(s.getId()+" " +s.getName());
}
}
}
}

Thanks


Related Tutorials/Questions & Answers:
how to return to main menu after adding all the info. - Java Beginners
how to return to main menu after adding all the info.  import...; System.out.println("School Registration System Main Menu...("School Registration System Main Menu"); System.out.println(); System.out.println
How to Create Animated Main Menu Application with Java Swnig Buttons - Java Beginners
How to Create Animated Main Menu Application with Java Swnig Buttons  Hello sir I want to display Main Menu after Log in i have created Log in Form but I want More attractive Animated Main Menu which includes Following
Advertisements
Adding pop up menu on headlines.
Adding pop up menu on Headlines Here you will learn sticking a pop up menu...() { if (window.mm_menu_0715193556_0) return; window.mm_menu_0715193556_0 = new Menu("... on to pop up menu, it opens the list of the menu automatically. For generating
I need to join three tables and return data that may not be in all three tables
I need to join three tables and return data that may not be in all three tables  How do I join three tables and return information even.... How do I get all the information for students from table A and table B even
How to return multiple values from a method - Java Beginners
How to return multiple values from a method  I came the following method "How do I return multiple values from a method?" posted elsewhere... result. Can someone tell me how my Driver.java program [see below] should
How to return multiple values from a method - Java Beginners
How to return multiple values from a method  I came the following method "How do I return multiple values from a method?" posted elsewhere... result. Can someone tell me how my Driver.java program [see below] should
How to Restore The Lossed data in MYSQL database after the System is formatted
How to Restore The Lossed data in MYSQL database after the System is formatted  How to Restore The Lossed data in MYSQL database after the System is formatted
how to disable back button of a browser after logging in? - JSP-Servlet
how to disable back button of a browser after logging in?  how to disable back button of a browser after logging in?  where is the source code
How I call the function union from the main - Java Interview Questions
How I call the function union from the main  Please, from public static void main(String[] args) I would like to call the function union and I... declared in main function //------------------------------- package model
date_sun_info
  date_sun_info() Function of PHP date_sun_info function returns... on success or False on failure.  Description on PHP date_sun_info() Function array date_sun_info ( int $time , float $latitude , float $longitude
return code - Java Beginners
: "); String name = scan.next(); break;//What code to use to return to main menu after...(System.in); int menu = 0; System.out.println("School Registration System Main...(System.in); int menu = 0; System.out.println("School Registration System Main
menu problem
menu problem  Hi to all , I am inserting a menu in my jsp page.i have downloaded(free) a menu .In which 4 files are as below. 1... not appear when i open index.html. i have searched it through all the files but i
creaing a menu - Java Beginners
creating a menu in JavaScript  How we can create a 3-level menu in java script
How to read all value from int buffer in java.
How to read all value from int buffer in java. In this tutorial, we will discuss how to read all value from int buffer in java.  IntBuffer API... the following methods: Return type Method Description
Vendor Info Error - WebSevices
Vendor Info Error  Hi, i wrote the code for Vendor Information using java script. If its full time the vendor info alert box is not displayed. And its contract or contract to hire the alert box is displayed. Tell me
jQuery Simple Drop Down Menu
jQuery Simple Drop Down Menu In this section, you will learn how to develop a simple drop down menu using jQuery. To develop a drop down menu we put the menu items in a unordered list .After that we design and manage it using CSS
Creating Menu - MobileApplications
to display a text on the screen. I need to know the following things: How to create our own menu system? How to navigate between the screens( eg from 1st...Creating Menu  Hi all, I am developing an application for nokia
seeking info - JSP-Servlet
and JSP-Servlet Programs.Then check your program for all necessary files.I guess
main method
main method  What is the argument type of a program's main() method
main method
main method  hello, Can I make multiple main methods in the same... can not make multiple main with in the same class program fails to compile. Compiler gives error that the main method is already defined in the class
Add menu - IDE Questions
Add menu  sir,i m student and learning netbean in which i want to develop web application but i cant find how to add menu item(not the case for java application where menu can be added from palette)so that when i run
JDialog return value to JDialog ????
JDialog return value to JDialog ????  hello all.... legend. JD1 = JDialog1 JD2 = JDialog2 JD1 open JD2......JD2 has any values, how I return...); jd2.setVisible(true); //now I need that JD2 return a value to JD1 JD2 make
PHP Return Statements
PHP Returning Statement Values: PHP Return statement is used to return a value.... In PHP we can return values, arrays, or object. If the function is called from within the function then execution will immediately stops, return is also used
Adding customitem in canvas in J2ME?
Adding customitem in canvas in J2ME?  In J2ME how should we add a customitem inside the canvas.Because i need to perform key event handling for customitem.The key event handling is allowed in canvas not in form.So i try to use
Adding checkbox to List as item
Adding checkbox to List as item   can we add checkox to List  ... main(String args[]) { JFrame frame = new JFrame...; } public boolean isSelected(){ return isSelected; } public void
J2ME Sub Menu - Java Beginners
J2ME Sub Menu  I am creating a J2ME midlet in which I have created a menu by adding different commands in it. Now for example my command list is as follows 1. A 2. B 3. C 4. D 5. Exit Now my question is I want to add
Return Array in PHP
Return Array in PHP  my question is how to return Array from PHP script
How do Unzip a directory and all its contents using ZipEntry class in java.
How do Unzip a directory and all its contents using ZipEntry class in java..., We will discuss about the isDirectory method and how to extract zip file. ... of ZipEntry   class return the name of associated entry. The mkdir() method
testcase for adding - JUNIT
testcase for adding  hi deepak...I am new to junit.can u send me a JUnit test case for adding or multiplying of two numbers.please i need it urgently
Swings Menu Bar - Java Beginners
Swings Menu Bar  Hello, I created a menu bar using Java Swings... n New Record, Edit Record etc are the menu items. Now, I want to display the appropriate fields according the menu Item selected..below it.. i.e. If we
Main function.. - Java Beginners
return the value when it exits main(): This is the entry point for the application...Main function..  Hi Friend.. public static void main(String args[]) What does it mean...public - static - void - main -(String args[]) Can u plz
Show all the entries of zip file.
Show all the entries of zip file. In this tutorial, We will  discuss how to show all the entries of a zip file.  The ZipFile   class is used.... It  provides the following methods: Return Type Method
Main method overloading
Main method overloading  Can we overload main()method
console application - text-based menu - Java Beginners
console application - text-based menu  Im doin a text-based menu... productmain will call. out.println("Enter menu choice:") ans = indata.next..., the class is not being called. how do i call: if (ans==1) addproduct ap = new
problem with main - Java Beginners
a problem. when i compile it appears this message: java.lang.NoSuchMethodError: main Exception in thread "main" . Should i put a main in another file? And how can..., This is an applet code and applet doesn't have main method therefore compile it and run
main func - Java Beginners
main func  why do we pass array of strings in main function of java?  Hi Friend, It is used to signify that the user may opt to enter parameters to the java program at command line. Thanks
adding background image - Java Beginners
adding background image  how do i add background image to this code: import javax.swing.*; import java.awt.*; import java.awt.event.... static void main (String[]args){ sampleProg frame = new
main() syntax - Java Beginners
main() syntax  Hi, I would like to know the complete structure of the main() in jdk1.5 with sample program. Regards, UsmanAli Shaik,  ...] [import statements] [class declaration] [main() method] For Example: package
Menu Control in Flex4
:Application> In this example you can see how we can use a Menu...Menu Control  in Flex4: The Menu contol is a pop-up control. It containes a submenu. You can select a indivisual item from menu control. You use only
adding data to the database with the use of jtable - Java Beginners
adding data to the database with the use of jtable  how can i add data to the database with the use of jtable. and also can able to view the records in the database in the table.. tnx :G
adding data to the database with the use of jtable - Java Beginners
adding data to the database with the use of jtable  how can i add data to the database with the use of jtable. and also can able to view the records in the database in the table.. tnx :G
Retrieve hardware info of a PC using servlet - JSP-Servlet
Retrieve hardware info of a PC using servlet  Hi,I hav a query related to java servlets.I wanted to know how to retrieve the hardware information using java servlets?I had gone through this link http://www.roseindia.net/software
Adding slash "\" character before quote "'" in a query
Adding slash "\" character before quote "'"...; Adding slash "\" character before quote "'"...){ if(str==null) return ""; StringBuffer s = new StringBuffer ((String) str
Adding a text file - Java Beginners
Adding a text file  Hello, I need a program that will search a text file of strings representing numbers of type int and will write the largest and the smallest numbers to the screen. The file contains nothing but strings
The "isThreadSafe" & "info" Attribute of JSP page directive
;info "attribute of JSP page directive. The "isThreadSafe"...;isThreadSafe" page directive is :      <%@page info="text" %>     Example : <%@page info="
Delete all rows using DBCP
;{   public static void main(String[] args) ... place all required jar files ie. commons-collections.jar, commons-dbcp.jar
ALL command - SQL
ALL Command in Java & SQL  Nee all commands in Java.  Dear Manoj, I didn't get u what do u mean by all command. could u please... possible options include: -g Generate all
Return Statement in PHP
In PHP Return is a Statment that returns value back to the calling program. For example if the Return Statment is called from within a function it will end the excution on it(return statment) and will return the value or argument back
eliminate the extra space after a </form> tag
eliminate the extra space after a tag  How can I eliminate the extra space after a tag
File download return value - Java Beginners
File download return value  How to get the return value of Open/Save/Cancel buttons in a File Download pop up using javascript
 

 

 

DMCA.com