Предмет: Информатика, автор: Fokkii

ПАСКАЛЬ АВС: ПРОБЛЕМА С СУММАТОРОМ

Пытаюсь сделать сумматор чисел, хочу сделать, чтобы 3-е слагаемое можно было добавить на выбор: словами "Да" или "Нет" (в программе вместо слов цифры через переменную char), почему-то поле ввода пропадает на этапе выбора. Укажите где ошибка и как ее исправить, отдельно отблагодарю за приложение примера работающей программы. Заранее спасибо!


restIess: свою программу прикрепите, так проще будет
Fokkii: Program Variables;
var
a,b,c,d:real;
e:string;

begin

writeln('######СУММАТОР######');
writeln(' ');
write('Введите первое слагаемое (вводите десятичные дроби через точку): ');
read(a);
write('Введите второе слагаемое: ');
read(b);
write('Введите второе слагаемое: ');
read(e );

if e = '0' then
begin
write('Введите третье слагаемое: ');
read (d);
c := (a+b+d);
writeln('Сумма слагаемых равна ',c,'.');
end;

if e = '1' then
begin
c := (a+b);
writeln('Сумма слагаемых равна ',c,'.');
end;

end.
restIess: write('Введите второе слагаемое: ');
read(e ); Для чего это вообще?
Fokkii: Это запись 3-его слагаемого должна была быть.
restIess: сначала вводим 3 слагаемых, затем спрашиваем у пользователя, хочет ли он чтобы прибавилось третьей, затем прибавляем или не прибавляем третье слагаемое, так?
Fokkii: Сперва спрашиваем, потом вводим.

Ответы

Автор ответа: kombat1488
1

program summator;

uses

crt;

var

a, b, c, s: real;

var

cmd: string;

begin

writeln('Сумматор v.2.0 активирован');

writeln;

writeln('Введите первое слагаемое:');

readln(a);

writeln('Введите второе слагаемое:');

readln(b);

writeln('Хотите добавить третье слагаемое?');

writeln(' ("Да" либо "Нет")');

readln(cmd);

if (cmd = 'Да') or (cmd = 'да') then

begin

writeln('Введите третье слагаемое:');

readln(c);

s := a + b + c

end

else

s := a + b;

writeln('Сумматор выполнил задачу: ', s);

readln;

end.


Fokkii: Спасибо, буду использовать!
Fokkii: А есть возможность без консоли?
Похожие вопросы
Предмет: Английский язык, автор: Ulya200134
TASK 1Liam Killeen.Liam Killeen is a rising star in cross-country mountain biking. He has raced since he was 12 and has had both successes and a)………. His worst moment so far was during a recent World Championship. His front tyre started to lose air in the last part of the race and he finished fourth. This was not the first time he'd been unlucky. In a previous race, it was raining heavily and he crashed his bike just minutes after the start.He often gets nervous before a race but thinks that this is a good thing. ‘Nervous energy makes you go faster and on the day, b) ……. The important thing is to stay positive.’Liam likes a hard race with steep climbs. ‘They make all the difference. You have to be really c)…….’ He also enjoys entering competitions at top levels as there are fewer riders in the race and this makes the start easier. ‘You can get into the front group more quickly.’Liam has been chosen to go to the Olympic Games and one day he would like to win a medal. ‘I'm still quite young and expect to be riding until my mid-thirties so d) ……. I know the Olympics are hard and I'll have to produce my best performance yet. But I feel confident.’Liam trains for 30 hours a week - always outside - and he reaches speeds of 65 kph. He thinks that cycling professionally is the best job in the world and e) ……. His advice to people starting to race is, ‘Be prepared for some hard work. If the training was easy, it wouldn't make you faster.’Level AI Choose the right word for each sentence.1) His ….. moment was during the world Championship.a) best   b) least   c) further    d) worst2) There is a good thing in getting ……. .a) important   b) nervous   c) quite   d) heavily3) Fewer ….. make the start easier.a) climbs     b) difference     c) riders     d) competitions4) Liam  ……. to be the Olimpic games.a) has gone   b) has won   c) has been choosen   d) has ridden        5) Liam reaches speeds of 65 kph because he trains only ……  .a) in the street  b) outside   c) inside   b) in the field12345Level BI Read the text and answer the questions.1) Why was Liam Killeen unlucky?2) Why is it a good thing to be nervous?3) What makes all the difference?4) Why does he feel confident himself?5) Why is cycling the best job for Liam Killeen?Level CI Complete the sentences.… it's all about winning.… would recommend it to anyone.… disappointments in that time .… I know it’s not possible to win.… I've got enough time to achieve my dream.… fit to get ahead.Помогите!!!!