/
kubkut
/
hw0
Обзор
Документация
Войти
/
kubkut
/
hw0
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Delivery.java
50 строк
2 KB
kubkut
Добрый вечер! дз
17 фев 2026, 19:01
Верифицирован
17 фев 2026, 19:01
50dd07a
Код
Авторство
О чём код?
package randomBox; import java.awt.geom.AffineTransform; import java.util.*; public class Delivery { public static void main(String[] args) { Map <Address, Integer> costPerAddress = new HashMap<>(); costPerAddress.put(new Address("Россия", "Санкт-Петербург"), 100); costPerAddress.put(new Address("Россия", "Уфа"), 110); costPerAddress.put(new Address("Россия", "Тула"), 120); costPerAddress.put(new Address("Беларусь", "Минск"), 200); costPerAddress.put(new Address("Казахстан", "Астана "), 300); Scanner scanner = new Scanner(System.in); int total = 0; Set <String> countries = new HashSet<> (); while (true) { System.out.println("Заполнение нового заказа."); System.out.print ("Введите страну: "); String country = scanner.nextLine(); System.out.println("Заполнение нового заказа."); System.out.print ("Введите город: "); String city = scanner.nextLine(); if ("end".equals(country) || "end".equals(city)) { break; } System.out.print("Введите вес (кг): "); int weight = Integer.parseInt(scanner.nextLine()); Address address= new Address(country, city); if (costPerAddress.containsKey(address)) { int currentPrice = weight * costPerAddress.get(address); total += currentPrice; countries.add(country); System.out.printf("Стоимость доставки составит: %d руб. \n", currentPrice); System.out.printf("Общая стоимость всех доставок: %d руб. \n", total); System.out.printf("Количество посещенных стран: %d. \n", countries.size()); } else { System.out.println("Доставки по этому адресу нет!"); } } } }