(Pascal)Программа перевода денег из одной валюты в другую по текущему курсу. В программе должен осуществляться запрос: вариант перевода (например: 1 - доллар в рубль, 2 - рубль в доллар); сумма денег; текущий курс.
program CurrencyConverter; var choice: integer; amount, rate, convertedAmount: real; begin writeln('Currency Converter'); writeln('1 - Convert from USD to RUB'); writeln('2 - Convert from RUB to USD'); write('Enter your choice: '); readln(choice); write('Enter amount: '); readln(amount); write('Enter current exchange rate: '); readln(rate); case choice of 1: begin convertedAmount := amount * rate; writeln('Amount in RUB: ', convertedAmount:0:2); end; 2: begin convertedAmount := amount / rate; writeln('Amount in USD: ', convertedAmount:0:2); end; else writeln('Invalid choice'); end; end.
Пример использования программы:
Currency Converter 1 - Convert from USD to RUB 2 - Convert from RUB to USD Enter your choice: 1 Enter amount: 100 Enter current exchange rate: 70 Amount in RUB: 7000.00
var
choice: integer;
amount, rate, convertedAmount: real;
begin
writeln('Currency Converter');
writeln('1 - Convert from USD to RUB');
writeln('2 - Convert from RUB to USD');
write('Enter your choice: ');
readln(choice);
write('Enter amount: ');
readln(amount);
write('Enter current exchange rate: ');
readln(rate);
case choice of
1: begin
convertedAmount := amount * rate;
writeln('Amount in RUB: ', convertedAmount:0:2);
end;
2: begin
convertedAmount := amount / rate;
writeln('Amount in USD: ', convertedAmount:0:2);
end;
else
writeln('Invalid choice');
end;
end.
Пример использования программы:
Currency Converter1 - Convert from USD to RUB
2 - Convert from RUB to USD
Enter your choice: 1
Enter amount: 100
Enter current exchange rate: 70
Amount in RUB: 7000.00