/
SofiMut
/
delivery
Обзор
Документация
Войти
/
SofiMut
/
delivery
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Main.java
58 строк
2 KB
Софья Степанова
upload files
23 июл 2025, 10:04
23 июл 2025, 10:04
f85b70a
Код
Авторство
О чём код?
import java.util.*; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); Map<Address, Integer> costPerAddress = new HashMap<>(); Set<String> geographicalReach = new HashSet<>(); costPerAddress.put(new Address("Таиланд", "Бангкок"), 0); costPerAddress.put(new Address("Таиланд", "Районг"), 50); costPerAddress.put(new Address("Таиланд", "Пхукет"), 300); costPerAddress.put(new Address("Россия", "Москва"), 1250); costPerAddress.put(new Address("Россия", "Екатеринбург"), 1000); costPerAddress.put(new Address("Россия", "Иркутск"), 700); costPerAddress.put(new Address("Китай", "Шанхай"), 650); costPerAddress.put(new Address("Китай", "Сиань"), 500); costPerAddress.put(new Address("Китай", "Куньмин"), 450); int totalPrice = 0; while (true) { System.out.println("НОВЫЙ ЗАКАЗ (или введите end для завершения) \n" + "Введите страну: "); String country = scanner.nextLine(); if (country.equals("end")) { 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 = weight * costPerAddress.get(address); totalPrice += price; geographicalReach.add(country); System.out.println("Стоимость доставки составит: " + price + " рублей.\n" + "Общая стоимость всех доставок: " + totalPrice + " рублей.\n" + "Товары уже доставляли в: " + geographicalReach); } else { System.out.println("Доставка по указанному адресу не осуществляется"); } } } }