Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package ass;
- /**
- *
- * @author NgT
- */
- import java.util.*;
- public class Ass {
- public static int show() {
- System.out.println("1. Add new students");
- System.out.println("2. Search for student based on his/her id");
- System.out.println("3. List all of the students");
- System.out.println("4. Delete student based on student id");
- System.out.println("0. Exit");
- String input;
- Scanner in = new Scanner(System.in);
- int a = 0;
- boolean ck = false;
- while (!ck) {
- try {
- System.out.print("Select your choice: ");
- a = Integer.parseInt(in.nextLine());
- if (a > 4 || a < 0) {
- throw new Exception();
- }
- ck = true;
- } catch (Exception e) {
- System.out.println("Wrong value!!! Retry");
- }
- }
- System.out.println("");
- return a;
- }
- public static void main(String[] args) throws Exception{
- // TODO code application logic here
- int choice = -1;
- StudentList s = new StudentList();
- while (choice != 0) {
- choice = show();
- switch (choice) {
- case 1:
- s.addNewStudent();
- break;
- case 2:
- s.searchID();
- break;
- case 3:
- s.listAllStudent();
- break;
- case 4:
- s.deleteID();
- break;
- default:
- choice = 0;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment