Вопрос задан 17.02.2019 в 18:29. Предмет Информатика. Спрашивает Осипова Дарья.

Задача по PHP. Дано вещественное число - цена 1 кг конфет. Вывести стоимость 1, 2, …, 10 кг конфет.

0 0
Перейти к ответам

Ответы на вопрос

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Брильова Мирослава.
<?php
foreach (array(1, 2, 3, 4,5,6,7,8,9,10) as $value) {   
$value = $value * 0.5;   
echo "{$value} ";
}?>
0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

Task: PHP Program to Calculate the Cost of Candy

To solve this task, we can use a simple PHP program to calculate the cost of 1, 2, ..., 10 kg of candy based on the given price per kilogram.

PHP Program:

```php

for ($i = 1; $i <= 10; $i++) { $totalCost = $pricePerKg * $i; echo "Cost of $i kg of candy: $totalCost
"; } ?> ```

This PHP program initializes the price per kilogram of candy and then uses a loop to calculate and display the cost of 1, 2, ..., 10 kg of candy based on the given price per kilogram.

Example Output:

- Cost of 1 kg of candy: 10 - Cost of 2 kg of candy: 20 - Cost of 3 kg of candy: 30 - Cost of 4 kg of candy: 40 - Cost of 5 kg of candy: 50 - Cost of 6 kg of candy: 60 - Cost of 7 kg of candy: 70 - Cost of 8 kg of candy: 80 - Cost of 9 kg of candy: 90 - Cost of 10 kg of candy: 100

This output demonstrates the cost of 1, 2, ..., 10 kg of candy based on the given price per kilogram.

I hope this helps! If you have any further questions or need additional assistance, feel free to ask.

0 0

Топ вопросов за вчера в категории Информатика

Последние заданные вопросы в категории Информатика

Задать вопрос