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

 
 


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

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 Pages:
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 update JTable after adding a row into database
how update JTable after adding a row into database  J have two... in JTable, and it's OK, but after adding a row into database table does't update. How update JTable after adding a row into database? package djilepak.javaclss.for
common Menu bar(toolBar) at the top of all view
common Menu bar(toolBar) at the top of all view  I creat on login page and after sign in I move to next page. Now I want to add menu bar at the top of my all view. Any one have any idea abt how to do
menu with scrollbar
); } public static void main(String arg[]) { menu m=new menu(); } }   Hi... static void main(String[]args){ menu me=new menu(); } } Thanks...menu with scrollbar  I want to use MenuBar with Scrollbar. I tried
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
How to refresh a jTable On adding or deleting record ....
How to refresh a jTable On adding or deleting record ....   Hii... from same panel and i want jtable to be refreshed after every addition... that updates the jtable automatically after some interval of time. import
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
return all rows mysql php
return all rows mysql php  How to find or return results that are not available in another table .. using join method in PHP and MYSql.   SELECT * FROM Declined LEFT JOIN Request ON Declined.RequestID
calculation after if. user input
calculation after if. user input  System.out.print ("please select... = aPrice * aQuantity; //calculate final cost by adding tax String fs1...; //calculate final cost by adding tax String fs2 = String.format(" your oranges
Menu Bar in Java
; a user can choose in a menu bar. In this Tutorial we want to describe you how... Menu Bar in Java       A Menu Bar is a set of option that allow the user to choose from
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 Bar in Java
choose in a menu bar. In this Tutorial we want to describe you how to create a Menu... Menu Bar in Java       A Menu Bar is a set of option that allow the user to choose from any one
Menu
Menu  Pl make a program which generates the following output. "Select from this menu" 1. Array 2. Stack 3. Queue. 4. Exit. If users press 1.... All the will give the user. Same as above. If user press 2. Stack
want to insert values in drop down menu in struts1.3
want to insert values in drop down menu in struts1.3  I am using DynaValidatorForm.please help me with inserting values in color drop down menu. I.... This later can takes some parameters explained here after. The plugin first read
Java Method Return Value
have a main method .The code show you how to get biggest number, for this we... Java Method Return Value       Java  method Return Value return to the code when
Return keyword
Return keyword  how do we use return in methods?   Java use of return keyword import java.util.*; public class ReverseString{ public...).reverse().toString(); return rev; } public static void main(String
adding loop
getPrice(){ return price; } public static void main(String...adding loop  Hi I have a program that is not compiling when I add...; } public String getCode(){ return code; } public
Java Method Return Multiple Values
Java Method Return Multiple Values In this section we will learn about how a method can return multiple values in Java. This example explains you how a multiple values can be return by a method. This example explains you all
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
adding two numbers - Java Beginners
adding two numbers  hii friends....... this is my program... Add2Numbers{ public static void main(String args[])throws IOException{ int[] x=new... no. is:"+s); } } in this program after running it will give one
adding some value to new column
adding some value to new column   how to update a column having some... in java using result set we can get all the column data but how to add these value... class UpdateColumn{ public static void main(String args[])throws Exception
What is the return type of the main method?
What is the return type of the main method?  hi, What is the return type of the main method? thanks   Hi, In the java programming the Main() method doesn't return anything hence declared void. In Java, you need
jsp- adding user defined functions to a jsp
"); return errorMessage; } %> Error: (error after...jsp- adding user defined functions to a jsp  Trying to write... and how to correct it. <% public String retrieveAndClearErrorMessage
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
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
in string how will write the return statement..........?
in string how will write the return statement..........?  import java.util.Scanner; class BinaryConversion12{ static int j=1; static int l=1; public static void main(String args[]){ int i=Integer.parseInt(args[0
How to return a string from a JTextField
How to return a string from a JTextField  Hi, Am new to java, and am.... The problem is i have no clue how to get the very string i need because i think... { public static void main(String[] args) { JFrame f=new JFrame
adding the delete code
bar to JFrame setJMenuBar(menuBar); //Add listener to all menu items...adding the delete code  hello sir... i need to add a delete button... JScrollPane pane; private JMenuBar menuBar; private JMenu menu; private JMenuItem
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
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... need return this result on JLabel to JD1. Please show me a how to or example
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
Create Menu Bar in SWT
Create Menu Bar in SWT       This section illustrates you how to create a menu bar. In SWT, the classes Menu and MenuItem of package org.eclipse.swt.widgets is allowed
How to remove all element from Hashset.
How to remove all element from Hashset. HashSet is set type Collection... all element of hashset. Code:  HashSetRemoveElement.java... RemoveAllElement { public static void main(String[] arg) { HashSet obHashSet = new
What is Public static void main
void, because main method  does not suppose to return any value, void...What is Public static void main In most of the Programming language, main... are the variation of main method. public static void main(String[] args) public
java main program
java main program  how to write a main program for the following code... + getCommonPrefix(compOne,compTwo) * (0.1*(1.0 - jw)); return res; } private...++; } } return matches; } private int getMissMatch(String s1, String
Exception in thread "main" org.hibernate.hql.ast.QuerySyntaxException: TESTING is not mapped [FROM TESTING]
to execute a sample app to test this and understand how it works.package main...-factory> </hibernate-configuration> Exception: `15 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.3.1.GA 31 [main] INFO
Java to extract info to HTML
Java to extract info to HTML  I need to write a java program that will extract information (events) from .ics files, such as those used in iCalendar... to extract each of the subcategories. Am I on the right track or am I doing this all
Crate a Popup Menu in Java
Create a Popup Menu in Java       Here, you will learn how to create a Popup menu in Java. Popup menu is the list of menu which is displayed at that point on the frame where
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
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
Delete All Records
Delete All Records       In this section, you will learn how to delete all record using jpa...: Student.java Main Class: JPADeleteAllRecords.java And its required jar files
JSP Dependent Drop Down Menu
to guide me in creating a drop down menu, where the first menu affects the second menu and it's selection. So in my database I have a category table that has a ID... searching the interwebs for the past hour so I don't know how useful links will be to me
seeking info - JSP-Servlet
and JSP-Servlet Programs.Then check your program for all necessary files.I guess
How to create dynamic buttons for adding products on a cart.
How to create dynamic buttons for adding products on a cart.  Hi. I... dynamic products from a database, and i would like to know how to group this products... containing the main table --> <div id="table"> <table
How to list all drives available in the system
How to list all drives available in the system In this section, you will learn how to list out all the drives available in the system.  Description... class. This will return an array of File objects for the drives
how to solve the nullPointer Exception in main - Java Beginners
how to solve the nullPointer Exception in main  New to Java ,pls help me how fix Null pointer Exception in main: two files , split .java another... main(String[] args) { String actualState; String str1 = "s0;input
adding a method to calculate a students grade
adding a method to calculate a students grade  The Following program...() { return studentID; } public String getName() { return name; } public float getMark() { return mark; } /* ------------THIS METHOD COULD
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
adding mouse listeners to drop target
adding mouse listeners to drop target  import java.awt.*; import... main(String[] args) { new JPanels(); } public JPanels() { JFrame frame... with adding mouse listeners to "table" which is drop target, to accept drop
Java String : Replace All
Java String : Replace All This section defines how to replace all character with specified character without using system methods. Replace All method : You can replace all specific character in a given string with another character

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.