/
akupan2012
/
Delivery
Обзор
Документация
Войти
/
akupan2012
/
Delivery
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Deliveri.java
54 строки
2 KB
akupan2012
upload files
10 дек 2025, 18:05
10 дек 2025, 18:05
9a9728b
Код
Авторство
О чём код?
import java.util.*; public class Deliveri { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); address address1 = new address("Россия", "Москва"); address address2 = new address("Россия", "Казань"); address address3 = new address("США", "Нью-Йорк"); address address4 = new address("Германия", "Берлин"); address address5 = new address("Китай", "Пекин"); Map<address, Integer> costPerAddress = new HashMap<>(); costPerAddress.put(address1, 200); costPerAddress.put(address2, 200); costPerAddress.put(address3, 500); costPerAddress.put(address4, 300); costPerAddress.put(address5, 250); int totalCost = 0; Set<String> countries = new HashSet<>(); System.out.println("Сервис международной доставки товаров"); System.out.println("================================="); while (true){ System.out.println("Заполнение нового заказа."); System.out.println("Введите страну (или нажмите end для завершения)"); String country= scanner.nextLine(); if ("end".equals(country)){ break; } System.out.println("Ведите город"); String city = scanner.nextLine(); System.out.println("Введите вес "); int weight = Integer.parseInt(scanner.nextLine()); address address = new address(country, city); if (costPerAddress.containsKey(address)){ int price = costPerAddress.get(address) * weight; totalCost += price; countries.add(country); System.out.printf("Стоимость доставки составит: %d руб.\n", price); System.out.printf("Общая стоимость всех доставок: %d руб.\n", totalCost); System.out.printf("Общая стоимость всех доставок: %d .\n", countries.size()); } else { System.out.println("Сюда доставки нету"); } } } }