Interfaces for managing a complex order system

TypeScript Hard interfaces

Task «Interfaces for managing a complex order system»

Develop a system of types and interfaces in TypeScript for processing orders in an online store with support for various payment methods, delivery options, and discounts. Implement a processOrder function that takes an order object and returns the total amount considering all applied rules. The order contains a list of items (each with a price and quantity), a payment method (card, cash, crypto), and a delivery method (pickup, courier, post). For card and crypto payments, a 5% discount applies; for pickup, a 10% discount applies; for courier delivery, a 15% surcharge applies; for post, a fixed cost of 300 applies. Discounts and surcharges are applied sequentially: first the payment discount, then the delivery discount/surcharge. The total amount is rounded to two decimal places.

Input Format

First line: number of products N (1 ≤ N ≤ 100). Then N lines: product name (string without spaces), price (floating point number), quantity (integer). Next line: payment method (card, cash, crypto). Last line: delivery method (pickup, courier, post).

Output Format

One number — the final sum with two decimal places.

Examples

Example 1

INPUT
5 5 4 3 2 1
OUTPUT
1 2 3 4 5 10
main.ts