Jump to content

3 posts in this topic

Recommended Posts

Posted

Hi I'm tasked to make a converter I got the conversions and I need to repeat the menu once again instead of killing it.

So I need to repeat the codes starting from the repeat to the, writeln('Tempature Conversion Program'); , up  to

writeln ('Converted temperature is: ', tconverted: 8:2, ' degrees ', scale);

readln;

program Project1;

{$mode objfpc}{$H+}

uses
  crt,
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes
  { you can add units after this };
var a, tconverted: real;
      f, scale: char;




begin
  Repeat
   clrscr;
  writeln('Tempature Conversion Program');
  writeln;
  writeln('1. Convert Celsius to Fahrenheit');
  writeln('2. Convert Fahrenheit to Celsius');
  writeln('3. Convert Celsius to Kelvin');
  writeln('4. Convert Kelvin to Celsius');
  writeln('5. Convert Kelvin to Fahrenheit');
  writeln('6. Convert Fahrenheit to Kelvin');
  writeln;
  writeln('7. Press 7 to exit');
  writeln;
  writeln ('Enter a number for temperature conversion ');
  readln (a);
  writeln ('Enter a number to convert from 1-6 or press 7 to exit');
  readln (f);
  if f in ['1'] then
    begin;
      tconverted := a * 9 / 5 + 32;
      scale:='F';
    end;

    if f in ['2'] then
    begin;
        tconverted:= (a - 32) * 5 / 9;
        scale:='C';
    end;

    if f in ['3'] then
    begin
      tconverted := a + 273.15;
      scale:='K';
    end;

    if f in ['4'] then
    begin
      tconverted := a - 273.15;
      scale:='C';
    end;

    if f in ['5'] then
    begin
      tconverted := a *  9/5 - 459.67;
      scale:='F';
    end;

    if f in ['6'] then
    begin
      tconverted :=  (a + 459.67) * 5 / 9;
      scale:='K';
    end;



  writeln ('Converted temperature is: ', tconverted: 8:2, ' degrees ', scale);
  readln;

  until ;
   clrscr;
     repeat;





end.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...

Important Information

We would like to place cookies on your device to help make this website better. The website cannot give you the best user experience without cookies. You can accept or decline our cookies. You may also adjust your cookie settings. Privacy Policy - Guidelines