PhoneBook | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

PhoneBook

you need to add the code. phone book: public static void main(String[] args) { String[][] telContacts = new String[10][4]; int lastEmptyCell = 0; Scanner scanner = new Scanner(System.in); while (true) { System.out.println("Select operation:"); System.out.println("(add) Add contact"); System.out.println("(update) Update contact"); System.out.println("(delete) Delete contact"); System.out.println("(show) Show contacts"); System.out.println("(exit) Exit"); String operation = scanner.next(); switch (operation) { case "add": { if (lastEmptyCell == telContacts.length) { //здесь код для увеличения размера массива - когда он заполнится } // здесь должен быть код для заполнения контакта: имя,фамилия,возраст,телефон lastEmptyCell++; break; } case "update": { System.out.println("Enter contact number:"); int contactIndex = scanner.nextInt(); if (contactIndex < lastEmptyCell) { // здесь должен быть код для изменения существующего контакта } else { System.out.println("No such contact!"); } break; } case "delete": { // здесь должен быть код удаления контакта break; } case "show": { System.out.println("Showing all contacts:"); // здесь должен быть код вывода всех контактов break; } case "exit": { System.out.println("Exiting TelBookApplication..."); return; } } } }

23rd Jul 2021, 1:17 PM
Best of Sport
Best of Sport - avatar
3 Answers
0
please, post your code in code playground.
23rd Jul 2021, 3:44 PM
Rellot's screwdriver
Rellot's screwdriver - avatar
23rd Jul 2021, 4:18 PM
Best of Sport
Best of Sport - avatar
0
this count is not working properly. it should: add a contact, update a contact (change name or number), delete, show a list of contacts and exit the program
28th Jul 2021, 12:26 PM
Best of Sport
Best of Sport - avatar