return code

return code

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 ????
return a value to JD1 [/code] JD2 make a search and save the result...JDialog return value to JDialog ????  hello all.... legend. JD1 = JDialog1 JD2 = JDialog2 JD1 open JD2......JD2 has any values, how I return
uitextfield hide keyboard on return
. I want to hide the keyboard when use clicks on the return button of the IOS keyboard in iPhone/iPad. How to hide the keyboard on return key. What is the best... code: -(BOOL) textFieldShouldReturn:(UITextField *)textField{ [textField
use of return statement
use of return statement  what is the use of return statement
uikeyboard disable return key
uikeyboard disable return key  uikeyboard - hot to disable return key
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
ModuleNotFoundError: No module named 'return'
ModuleNotFoundError: No module named 'return'  Hi, My Python... 'return' How to remove the ModuleNotFoundError: No module named 'return'... to install padas library. You can install return python with following command
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
code
code  write a program to encrypt and decrypt the cipher text "adfgvx"   Hi Friend, Try the following code:ADS_TO_REPLACE_1 import...) buf[i] & 0xff, 16)); } return buffer.toString
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..., true); jd2.setVisible(true); //now I need that JD2 return a value
php return true false
php return true false  i wanted to create php function that returns true/false
code
); } function DisplayText() { alert( m_text ); return; } function SetData( myVal
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
Code
Code  code for connecting c lang to database
code
code    how to write this in java
code
code  code for android sample program
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
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
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
ModuleNotFoundError: No module named 'flake8-assign-and-return'
ModuleNotFoundError: No module named 'flake8-assign-and-return'  Hi...: No module named 'flake8-assign-and-return' How to remove the ModuleNotFoundError: No module named 'flake8-assign-and-return' error? Thanks  
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
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
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
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
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.ADS_TO_REPLACE_1
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
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
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
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
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
ModuleNotFoundError: No module named 'odoo10-addon-account-payment-return'
ModuleNotFoundError: No module named 'odoo10-addon-account-payment-return' ...: ModuleNotFoundError: No module named 'odoo10-addon-account-payment-return' How to remove...-return' error? Thanks   Hi, In your python environment you have
ModuleNotFoundError: No module named 'odoo10-addon-pos-order-return'
ModuleNotFoundError: No module named 'odoo10-addon-pos-order-return'  ...: No module named 'odoo10-addon-pos-order-return' How to remove the ModuleNotFoundError: No module named 'odoo10-addon-pos-order-return' error
ModuleNotFoundError: No module named 'odoo10-addon-pos-order-return'
ModuleNotFoundError: No module named 'odoo10-addon-pos-order-return'  ...: No module named 'odoo10-addon-pos-order-return' How to remove the ModuleNotFoundError: No module named 'odoo10-addon-pos-order-return' error
ModuleNotFoundError: No module named 'odoo11-addon-account-payment-return'
ModuleNotFoundError: No module named 'odoo11-addon-account-payment-return' ...: ModuleNotFoundError: No module named 'odoo11-addon-account-payment-return' How to remove...-return' error? Thanks   Hi, In your python environment you have

Ads