Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4095
Number of posts: 14004

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Creating a program Help please Posted by Pascallop on 23 Mar 2011 at 1:23 PM
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
Report
Re: Creating a program Help please Posted by _Atex_ on 25 Mar 2011 at 9:18 PM
: 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.
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.




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.