mdclcompany
?>

Виконайте фрагмент програми та з'ясуйте, якими будуть значення змінних після його завершення ​

Информатика

Ответы

Shishkinaanasta1997

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.

 

matterfixed343
import java.util.*;
import java.lang.*;

class {
public static void main(String[] args){

Scanner sc = new Scanner(System.in); // то для ввода

int ecoPrice = 0;
int businesPrice = 2 * ecoPrice;
int placeeco;
int placeBus;

System.out.print("Enter scolyco ostalos eco mest): ");
placeeco = 120 - sc.nextInt();
System.out.print("enter ecoprice: ");
ecoPrice = sc.nextInt();
System.out.print("Enter scolyco ostalos bus mest): ");
placeBus = 40 - sc.nextInt();
System.out.print("enter busprice");
businesPrice = sc.nextInt();

int plus = placeeco * ecoPrice + businesPrice * placeBus;
System.out.print("Dohod: " + plus);
}
}

поставь лучший ответ

Ответить на вопрос

Поделитесь своими знаниями, ответьте на вопрос:

Виконайте фрагмент програми та з'ясуйте, якими будуть значення змінних після його завершення ​
Ваше имя (никнейм)*
Email*
Комментарий*

Популярные вопросы в разделе

universal21vek116
gaina6678
Vladislav98
mel9152480522
Chausmonk4
asviridova07194
perfectorg
Paradismebel
manuchar-formen2
orange-salon-job77
NurlanAleksandrovich
sveta300856729
magichands68
Борисович409
Ushakova Sakhno