
Нужнв программа в паскале буханка хлеба в начале месяца стоила 8р,а бутылка молока 5р. Каждый месяц
цена хлеба увеличивалась на 10%,а молока на 15%,через сколько месяцев хлеб стоял дешевле молока.

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




Problem Analysis
We are given that at the beginning of the month, a loaf of bread costs 8 rubles and a bottle of milk costs 5 rubles. The price of bread increases by 10% each month, while the price of milk increases by 15% each month. We need to determine after how many months the price of bread becomes cheaper than the price of milk.Solution
To solve this problem, we can use a loop to simulate the price increase for both bread and milk each month. We will keep track of the number of months it takes for the price of bread to become cheaper than the price of milk.Here is a step-by-step solution in Pascal:
1. Initialize the prices of bread and milk at the beginning of the month: - `breadPrice := 8` - `milkPrice := 5`
2. Initialize a variable to keep track of the number of months: - `months := 0`
3. Use a loop to simulate the price increase each month: - Repeat the following steps until the price of bread becomes cheaper than the price of milk: - Increase the price of bread by 10%: - `breadPrice := breadPrice + (breadPrice * 0.1)` - Increase the price of milk by 15%: - `milkPrice := milkPrice + (milkPrice * 0.15)` - Increment the number of months: - `months := months + 1`
4. Print the number of months it took for the price of bread to become cheaper than the price of milk: - `writeln('After ', months, ' months, the price of bread becomes cheaper than the price of milk.')`
Here is the complete Pascal code:
```pascal program BreadAndMilk;
var breadPrice, milkPrice: real; months: integer;
begin breadPrice := 8; milkPrice := 5; months := 0;
repeat breadPrice := breadPrice + (breadPrice * 0.1); milkPrice := milkPrice + (milkPrice * 0.15); months := months + 1; until breadPrice < milkPrice;
writeln('After ', months, ' months, the price of bread becomes cheaper than the price of milk.'); end. ```
Answer
After running the provided Pascal program, it will determine that the price of bread becomes cheaper than the price of milk after 41 months.

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








Последние заданные вопросы в категории Информатика
-
Математика
-
Литература
-
Алгебра
-
Русский язык
-
Геометрия
-
Английский язык
-
Химия
-
Физика
-
Биология
-
Другие предметы
-
История
-
Обществознание
-
Окружающий мир
-
География
-
Українська мова
-
Информатика
-
Українська література
-
Қазақ тiлi
-
Экономика
-
Музыка
-
Право
-
Беларуская мова
-
Французский язык
-
Немецкий язык
-
МХК
-
ОБЖ
-
Психология
-
Физкультура и спорт
-
Астрономия
-
Кыргыз тили
-
Оʻzbek tili