Creating a program Help please - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Creating a program Help please

PascallopPascallop Posts: 1Member
Hello i'd appreciate if someone could help me with creating a program


Basically i have to create a main program whih a list appears and a user can select one of the following

Press 1 for farenheit - celcius
press 2 for dollars - pounds
press 3 for cm - inches
press 4 for lbs - stone

the user would then press a number for example they press number 3. The user then enters a number which then is converted from cm - inches.

The program then stops and asks the user if he/she wants to continue if the answer is yes then it will take them back to the main program where they can select a new number to convert something else such as lbs, dollars etc.

I'm very new to pascal, i'd appreciate if someone could help me on this as i really don't have a clue how to do it :(. Thanks

Comments

  • _Atex__Atex_ Posts: 163Member
    : Basically i have to create a main program whih a list appears and a
    : user can select one of the following
    :
    : Press 1 for farenheit - celcius
    : press 2 for dollars - pounds
    : press 3 for cm - inches
    : press 4 for lbs - stone
    :
    : the user would then press a number for example they press number 3.
    : The user then enters a number which then is converted from cm -
    : inches.
    :
    : The program then stops and asks the user if he/she wants to continue
    : if the answer is yes then it will take them back to the main program
    : where they can select a new number to convert something else such as
    : lbs, dollars etc.
    :
    :


    This code should put you on the track, all you have to do is just expand it to have all the menu items working. You can use the temp. conversion function as a template and write the conversion parts for each of the functions.[code][color=Blue]uses crt;


    function convert_farenheit:boolean;
    var fvalue:real;
    ch:char;
    begin
    write(#13#10#248'F=');readln(fvalue);
    {...}
    { conversion part goes here }
    {...}
    writeln('Press: Esc to Quit, Enter to Continue');
    repeat ch:=readkey; until ((ch=#27) or (ch=#13));
    convert_farenheit:=ch=#13;
    end;


    function main_loop:boolean;
    var ch:char;
    begin
    writeln(#13#10#13#10'Press: 1 - Farenheit <=> Celsius');
    writeln(' 2 - Dollars <=> Pounds');
    writeln(' 3 - Cm <=> Inches');
    writeln(' 4 - Lbs <=> Stone');
    writeln(' 5 - Exit');
    repeat
    ch:=readkey;
    case ch of
    '1':main_loop:=convert_farenheit;
    {'2':...
    '3':...
    '4':... }
    '5':main_loop:=false;
    end;
    until (ch in ['1'..'5']);
    end;


    begin while main_loop do;end.[/color][/code]
Sign In or Register to comment.