1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

For loops and while do in pascal

Discussion in 'Software Development' started by scoobydrew, Dec 16, 2001.

Thread Status:
Not open for further replies.
  1. scoobydrew

    scoobydrew Thread Starter

    Joined:
    Dec 16, 2001
    Messages:
    3
    :confused:

    i have written the following program

    program test;
    var alt, dis, answer : integer;
    var sum : real;
    begin

    writeln ('would you like to fly at a specific height? 1 for yes 2 for no');
    readln (answer);
    if (answer = 1) then
    begin
    writeln ('enter chosen cruising level');
    readln (alt);
    writeln ('enter flight length');
    readln (dis);
    sum := (((750.44-(0.013717*alt))/60)*((dis/5)-((alt/1000)*2)))+(((750.44-(0.013717*(alt/2)))/60)*((alt/1000)*1.4))+(((750.44-(0.013717*(alt/2)))/60)*((alt/1000)*0.9));
    writeln ('the total fuel consumption for this flight is, sum :4:2 , kgs')
    end
    else;
    begin
    writeln ('enter distance of flight');
    readln (dis);

    This is as far as i've got with my program. i now need the program to work out the optimum cruising level for the distance entered. i know i will have to use a for loop or while do command but don't know how they work properly.
    i need to let the end user enter the distance they want to travel and then for the program to test the fuel consumption for each height upto 30,000ft for that distance and then display the best result (the one that uses the least amount of fuel).
    The range is between 0 - 30,000ft in intervals of 1,000.

    if you could let me know how to finsh this program or how to improve it i would be grateful.

    thanx
    scoobydoobydrew
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/61946

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice