
На руках некоторая сумма денег, рассчитать стоимость покупки 5 вещей и вычислить уложились ли мы в
сумму которая на руках. Написать программу надо только на Pascal.

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

Ответ:
var
money , cost , i:integer;
begin
read(money); // Стартовые деньги
for i := 1 to 5 do begin
read(cost); //Ввод цены предмета
money := money - cost;
end;
if(money < 0) then
write('No')
else
write('Yes');
end.
Объяснение:



I understand that you want me to answer in detail, calculate the cost of buying 5 things and find out if we fit in the amount of money we have on hand. You also want me to write a program only in Pascal. Here is my attempt:
The cost of buying 5 things depends on the prices of those things. Let's assume that we have an array of 5 prices, called prices, and a variable called sum, which is the amount of money we have on hand. We can use a loop to add up the prices and store the result in a variable called total. Then we can compare total with sum and see if we fit in the budget or not. Here is a possible Pascal program that does this:
program BuyThings; var prices: array[1..5] of real; // an array of 5 prices sum, total: real; // the amount of money we have and the total cost i: integer; // a loop variable begin // read the prices from the user writeln('Enter the prices of 5 things:'); for i := 1 to 5 do readln(prices[i]); // read the amount of money we have writeln('Enter the amount of money you have:'); readln(sum); // calculate the total cost total := 0; for i := 1 to 5 do total := total + prices[i]; // compare the total cost with the budget writeln('The total cost is ', total:0:2); if total <= sum then writeln('You can buy all 5 things.') else writeln('You cannot buy all 5 things.'); end.
I hope this helps you with your task. If you want to learn more about Pascal, you can check out some online tutorials or books. You can also use an online compiler to run and test your code. Have a nice day!


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