/
ArtTip
/
HW_HASH
Обзор
Документация
Войти
/
ArtTip
/
HW_HASH
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Main.java
50 строк
2 KB
ArtTip
update Main.java
27 фев 2025, 15:48
27 фев 2025, 15:48
867b6f8
Код
Авторство
О чём код?
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> set = new HashSet<>(); int weight; int tax; int count = 0; int unique = 0; Address addressRussiaKrasnoyarsk = new Address("Россия", "Красноярск"); Address addressEnglandLondon = new Address("Англия", "Лондон"); Address addressChinaBeijing = new Address("Китай", "Пекин"); Address addressJapanTokyo = new Address("Япония", "Токио"); costPerAddress.put(addressRussiaKrasnoyarsk, 1000); costPerAddress.put(addressEnglandLondon, 700); costPerAddress.put(addressChinaBeijing, 1500); costPerAddress.put(addressJapanTokyo, 5000); while (true) { System.out.println("\nЗаполнение нового заказа."); System.out.print("Введите страну: "); String country = scanner.nextLine(); if (country.equals("end")) { break; } System.out.print("Введите город: "); String city = scanner.nextLine(); System.out.print("Введите вес (кг): "); weight = Integer.parseInt(scanner.nextLine()); Address comparison = new Address(country, city); if (costPerAddress.get(comparison) == null) { System.out.println("Доставки по этому адресу нет "); } else { set.add(country); unique = set.size(); tax = costPerAddress.get(comparison) * weight; System.out.printf("Стоимость доставки составит: %d \n", tax); count += tax; System.out.printf("Общая стоимость всех доставок: %d \n", count); System.out.printf("Количество уникальных стран: %d \n", unique); } } } }