Challenge: Vending Machine
Завдання
Swipe to start coding
Create a function getSnackPrice that determines the price of a snack in a vending machine based on the snack type and size.
- The function should receive two integers:
snackTypeandsize. - If
snackTypeis 1 (chips):- If
sizeis 1, price is 10; - If
sizeis 2, price is 15; - For any other
size, price is 12.
- If
- If
snackTypeis 2 (chocolate):- If
sizeis 1, price is 20; - If
sizeis 2, price is 25; - For any other
size, price is 22.
- If
- For any other
snackType, price is 0. - The function should return the price as an integer.
Рішення
Все було зрозуміло?
Дякуємо за ваш відгук!
Секція 2. Розділ 3
single
Запитати АІ
Запитати АІ
Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат
Suggested prompts:
Can you explain this in more detail?
What are the main benefits or drawbacks?
Can you give me an example?
Чудово!
Completion показник покращився до 9.09
Challenge: Vending Machine
Свайпніть щоб показати меню
Завдання
Swipe to start coding
Create a function getSnackPrice that determines the price of a snack in a vending machine based on the snack type and size.
- The function should receive two integers:
snackTypeandsize. - If
snackTypeis 1 (chips):- If
sizeis 1, price is 10; - If
sizeis 2, price is 15; - For any other
size, price is 12.
- If
- If
snackTypeis 2 (chocolate):- If
sizeis 1, price is 20; - If
sizeis 2, price is 25; - For any other
size, price is 22.
- If
- For any other
snackType, price is 0. - The function should return the price as an integer.
Рішення
Все було зрозуміло?
Дякуємо за ваш відгук!
Секція 2. Розділ 3
single