Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Simple Life Calculator

program SimpleLifeCalculator;

var
  mode, quitString: string;

procedure VAT ();
var
  money: real;
begin
  write('Enter amount of money (pounds): ');
  readln(money);
  writeln('VAT: ', (money * 0.2):0:2, ' pounds');
  writeln('Gross amount: ', (money * 1.2):0:2, ' pounds');
end;

procedure tax ();
var
  income: integer;
  taxMultiplier: real;
begin
  write('Enter annual income (pounds): ');
  readln(income);
  if income <= 11850 then
    taxMultiplier := 0
  else if income <= 46350 then
    taxMultiplier := 0.2
  else if income <= 150000 then
    taxMultiplier := 0.4
  else
    taxMultiplier := 0.45;
  writeln('Tax: ', round(income * taxMultiplier));
  writeln('Final income: ', round(income * (1 - taxMultiplier)));
end;

procedure timesTable ();
var
  number, terms, termCount: integer;
begin
  write('Enter a number: ');
  readln(number);
  writeln('How many terms? ');
  readln(terms);
  for termCount := 1 to terms do
    writeln(number * termCount);
end;

begin
  repeat
    write('VAT (1), Tax (2) or Times Table (3): ');
    readln(mode);
    if mode = '1' then
      VAT()
    else if mode = '2' then
      tax()
    else if mode = '3' then
      timesTable();
    write('Would you like to quit? (Y/N): ');
    readln(quitString);
  until upcase(quitString) = 'Y';
end.

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.