Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main2 {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- Main students = new Main();
- String input="";
- while (!input.equals("END")) {
- input = scan.nextLine();
- if (input.equals("ADD")) {
- System.out.println("The student you want to add: ");
- int i = scan.nextInt();
- String n = scan.next();
- String m = scan.next();
- String u = scan.next();
- String j = i + " " + n + " " + m + " " + u;
- if(students.contains(j) == false) {
- students.add(j);
- }
- System.out.println();
- }else if(input.equals("REM")){
- System.out.println("The student you want to remove: ");
- int i = scan.nextInt();
- String n = scan.next();
- String m = scan.next();
- String u = scan.next();
- String j = i + " " + n + " " + m + " " + u;
- if(students.contains(j) == true) {
- students.remove(j);
- }
- System.out.println();
- }else if(input.equals("CNT")){
- System.out.println("\nSize of Dictionary : " + students.getLength());
- System.out.println();
- }else if(input.equals("PRN")){
- System.out.println("Now your shopping list contains: ");
- for (int i = 0; i < students.getLength(); i++) {
- System.out.println(students.elementAt(i));
- System.out.println();
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment