• В аэробусе, вмещающем 160 пассажиров, три четверти мест находятся в салонах экономического класса и одна четверть мест - в салоне бизнес-класса. 
    Стоимость билета в салоне бизнес класса составляет х рублей, что в два раза выше стоимости билета в салонах экономического класса.
    Разработайте программу, которая вычислит сумму денег, полученную авиакомпанией от продажи билетов на этот рейс, если известно, что остались нераспроданными а билетов бизнес-класса и b билетов экономического класса. 
    Выделите все этапы решения этой задачи и опишите свои действия на каждом из них.

Ответы 1

  • 1. Подумать над алгоритмом2. Вот сам алгоритм:а. спросить у пользователя значенияб. расчитать ответв. выдать ответ на экран3. Написать код в паскале4. Исправить ошибки компиляции5. Протестировать, вводить разные числа6. обнаружила, что если вводить числа наугад ответ получается отрицательным иногда7. Вставить код проверки введенных пользователем значений8. убрать ошибки компиляции9. протестировать10. готово

     

    А вот и сама программа:

     

    program aerobus;uses crt;const TotalPlace = 160;var businessPlaces, economyPlaces:integer;businessPrice, economyPrice:real;totalCharge:real;a,b:integer;correctInput:boolean;begin clrscr; businessPlaces:=TotalPlace div 4; economyPlaces:= TotalPlace - businessPlaces; writeln('business places count: ', businessPlaces); writeln('economy places count: ', economyPlaces); correctInput:=false; while not correctInput do begin write('Please Input Business Class Ticket Price: '); readln(businessPrice); if(businessPrice>0) then begin correctInput:=true; end else begin writeln('The price should be a positive number, please try again'); end; end; economyPrice:=businessPrice/2; writeln('Economy Ticket Price is: ', economyPrice:0:2); correctInput:=false; while not correctInput do begin write('How many business tickets are left?: '); readln(a); if(a>=0) and (a<=businessPlaces)then correctInput:=true; if(a<0) then begin writeln('Please input a positive number or 0, please try again'); end; if(a>businessPlaces) then begin writeln('Please input a number which is less or equal to the tolal business place count, please try again'); end; end;

    correctInput:=false; while not correctInput do begin write('How many economy tickets are left?: '); readln(b); if(b>=0) and (b<=economyPlaces)then correctInput:=true; if(b<0) then begin writeln('Please input a positive number or 0, please try again'); end; if(b>economyPlaces) then begin writeln('Please input a number which is less or equal to the tolal economy place count, please try again'); end;

    end; totalCharge:=(businessPlaces-a)*businessPrice; totalCharge:=totalCharge+(economyPlaces-b)*economyPrice; writeln('The total charge is:', totalCharge:0:2); writeln; writeln('Press enter to exit'); readln;end.

     

  • Добавить свой ответ

Еще вопросы

Войти через Google

или

Забыли пароль?

У меня нет аккаунта, я хочу Зарегистрироваться

How much to ban the user?
1 hour 1 day 100 years