Вопрос задан 30.10.2023 в 02:55. Предмет Информатика. Спрашивает Фламенкова Саша.

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

сумму которая на руках. Написать программу надо только на Pascal.
0 0
Перейти к ответам

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

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Каргин Иван.

Ответ:

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.

Объяснение:

0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

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!

0 0

Похожие вопросы

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

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

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