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




Have Programming Question? Ask it here!
 
 
 


Alex
return code
1 Answer(s)      4 years and 10 months ago
Posted in : Java Beginners



Advertisement
View Answers

October 7, 2009 at 5:41 PM


Hi Friend,

Try the following code:

/*import java.util.Scanner;
public class RegistrationSystem {

public static void main(String[]args){
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();
}
}
}
*/
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.println("4. Exit");
boolean quit = false;
do{
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());
}
break;
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);
break;
case 3:
System.out.println("Id Name");
for (Student s : list){
System.out.println(s.getId()+" " +s.getName());
}
break;
case 4:
quit = true;
break;
default:
System.out.println("Invalid Entry!");
}
}

while (!quit);
}
}

Thanks


Related Tutorials/Questions & Answers:
return code - Java Beginners
: "); String name = scan.next(); break;//What code to use to return to main menu after...return code  import java.util.Scanner; public class... the following code: /*import java.util.Scanner; public class
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
Advertisements
What it will return ..... ?
What it will return ..... ?   import java.util.*; public class Name { private final String first, last; public Name(String first, String last...) { if (!(o instanceof Name)) return false; Name n = (Name)o; return n.first.equals
return item in jquery
return item in jquery  How to return items/variables in JQuery?   See the code below to find out how to return an Item in Jquery: function... for the variable item } return item; } var item = findItem(); // do
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 this values to JD1 ??? [code] // JD1 open JD2 JD2 jd2 = new JD2(null
uikeyboard disable return key
uikeyboard disable return key  uikeyboard - hot to disable return key
use of return statement
use of return statement  what is the use of return statement
function to return value in java
function to return value in java  How to return maximum value in java?   Return Value in Java
Return Array in PHP
Return Array in PHP  my question is how to return Array from PHP script
Java Method Return Value
Java Method Return Value       Java  method Return Value return to the code when... value. In case you try to get the return value from void .the code show you
php return true false
php return true false  i wanted to create php function that returns true/false
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
uikeyboard done button/return button
uikeyboard done button/return button  Hi everyone!!! Just worried about ..how to return the UIKeyboard on done or return button click in my iPhone application. Thanks   Hi, Find the given code that will allow you
Return Java Keyword
Return Java Keyword       The return is a keyword defined in the java programming language. Keywords... in java programming language likewise the return keyword indicates the following
Search and return lines of text file
Search and return lines of text file  I wrote the following code...)) { System.out.println(line); RL = line; //return "Lines: "+RL; (if I write... (IOException ex) { ex.printStackTrace(); } return "Lines: "+RL
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
PHP Functions and Return values
PHP Functions and Return values A function is the a block of code whom you can... the code into a function. A function will only be executed by a call... of the function is given below : function functionName() { code to be executed
return 0 vs exit 0
return 0 vs exit 0  what is the difference between return 0 and exit 0 in c? i could not find any difference in their behaviour (both terminates the process execution) in a program
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
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
return the position of last occurrence of an element
return the position of last occurrence of an element  A method " findLast(E element) " returns the position of the last occurrence of the given element. If this element is not in the list, then the null reference should
return the position of last occurrence of an element
return the position of last occurrence of an element  A method " findLast(E element) " returns the position of the last occurrence of the given element. If this element is not in the list, then the null reference should
Return Value from One Form
Return Value from One Form  I have two buttons in main form client and bank.when i click client button new form will open, in this dedupe button is there.when i click dedupe button another form will open. i want to get a field
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 trying to get a string from a JTextField so that I can compare it with another String using either compare or equals or compareTo methods of the String class
Java error missing return statement
, then you must specify the return type in it. The given below code is missing a return statement in the non-void method so, whenever the compiler execute the code the code returns a missing return statement error. There are two way to resolve
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
carriage return with javascript - JSP-Interview Questions
carriage return with javascript  Dear, Please in one webpage, I need a carriage return in javsacript code \r. I use it BUT no effects. Can you help me. Regards
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
SQL select statement doesn't return any rows,
SQL select statement doesn't return any rows,  When an SQL select statement doesn't return any rows, is an SQLException thrown
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
calling webservices that return complexTypes in android using ksoap2
calling webservices that return complexTypes in android using ksoap2   Here's my code for android application,to call aweb service method and return..._niladhari, menu); return true; } private class SupportThread extends
Return Value From Event - Java Beginners
Return Value From Event  I would like to call a method that returns... } return value } My problem... for the listener and then return the value as modified. Thanks
calling webservices that return complexTypes in android using ksoap2
calling webservices that return complexTypes in android using ksoap2   Can anyone direct me to a site or show me an example ,on how to call a webservice which returns a complexType as the result, in an android app
code
code  write a program to encrypt and decrypt the cipher text "adfgvx"   Hi Friend, Try the following code: import java.security....; 0xff, 16)); } return buffer.toString(); } public static
java method return type : - Java Beginners
java method return type :  i have one question regarding methods,,, if we create a method with return type as class name (public employee addemp(int,int))what should be its return type.....and if any know this pls explain
code
code  code for android sample program
code
code    how to write this in java
Code
Code  code for connecting c lang to database
code for this is
code for this is  a b c d c b a a b c c b a a b b a a a code
code
code  please provide code for custom tags.by using currdate tag we need to get current date?please give me code
code
code   hi I need help in creating a java code that reminds user on a particular date about their festival. i have no clue of how to do it.. am looking forward to seek help from you
code
the correct code for a program.The output of the program is listed below...: {Block 5} ADDRESS-3: {San Juan} POST CODE:{6745} ENTER CODE (XX TO stop) CODE:{FF1} QUANTITY:{2} CODE:{TR4} QUANTITY:{1} CODE:XX INVOICE FOR YOUR ORDER Harry
code
code to create the RMI client on the local machine: import java.rmi.*; public... : "+e); } } } However, when the preceding code is executed it results... the correct code
code
); } function DisplayText() { alert( m_text ); return; } function SetData( myVal
code
code  i have four textboxes.whenever i click on up,down,left or down arrows then the cursor move to another textbox based on the key pressed.i want code for this in javascript
code
line of code to print the amount he should be paid as allowance
How to get javascript function return value in xsl - XML
How to get javascript function return value in xsl  Hi friends , i... to xsl variable with small piece of code,i need immediately , if anybody plz send ur...; Hi friend, Code to help in solving the problem
Passing java variables from JSP to Servlet - return null values
Passing java variables from JSP to Servlet - return null values  I... the java code of my JSP. In JSP page I did, String msg="hello... to get java variables from JSP tp servlet? If there is some error in my code
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... the following code: import java.io.*; import java.util.*; class Student...() { return id; } public String getName() { return name; } } public class
 

 

 

DMCA.com