StartprogrammingusingObjectPascal:RestaurantProgramUsingFunctions: Difference between revisions

From 흡혈양파의 번역工房
Jump to navigation Jump to search
(SPOP 함수를사용한식당프로그램 페이지 추가)
 
(오류수정)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
===함수를 사용한 식당 프로그램===
==함수를 사용한 음식점 프로그램==


<syntaxhighlight lang="pascal">
<syntaxhighlight lang="pascal">
Line 5: Line 5:
begin
begin
     Writeln('Welcome to Pascal Restaurant. Please select your order');
     Writeln('Welcome to Pascal Restaurant. Please select your order');
     Writeln('1 Chicken          (10$)');
     Writeln('1 - Chicken          (10$)');
     Writeln('2 Fish                  (7$)');
     Writeln('2 - Fish                  (7$)');
     Writeln('3 Meat                (8$)');
     Writeln('3 - Meat                (8$)');
     Writeln('4 - Salad              (2$)');
     Writeln('4 - Salad              (2$)');
     Writeln('5 - Orange Juice (1$)');
     Writeln('5 - Orange Juice (1$)');
     Writeln('6 Milk                  (1$)');
     Writeln('6 - Milk                  (1$)');
     Writeln;
     Writeln;
end;
end;
Line 48: Line 48:


         Total := Total + Price;
         Total := Total + Price;
     until (Selection = ‘x’) or (Selection = ‘X’);
     until (Selection = 'x') or (Selection = 'X');
     Writeln(‘Total price                  = ,Total);
     Writeln('Total price                  = ',Total);
     Write('Press enter key to close');
     Write('Press enter key to close');
     Readln;
     Readln;
end.
end.
</syntaxhighlight>
</syntaxhighlight>
[[Category:StartprogrammingusingObjectPascal]]
[[Category:StartprogrammingusingObjectPascal]]

Latest revision as of 11:36, 4 April 2013

함수를 사용한 음식점 프로그램

procedure Menu;
begin
    Writeln('Welcome to Pascal Restaurant. Please select your order');
    Writeln('1 - Chicken          (10$)');
    Writeln('2 - Fish                  (7$)');
    Writeln('3 - Meat                (8$)');
    Writeln('4 - Salad               (2$)');
    Writeln('5 - Orange Juice (1$)');
    Writeln('6 - Milk                  (1$)');
    Writeln;
end;

function GetOrder(AName: string; Minutes, Price: Integer): Integer;
begin
    Writeln('You have ordered : ', AName, ', this will take ',
         Minutes, ' minutes');
    Result := Price;
end;

// Main application
var
    Selection: Char;
    Price: Integer;
    Total: Integer;
begin
    Total := 0;
    repeat
        Menu;
        Write('Please enter your selection: ');
        Readln(Selection);
        case Selection of
            1: Price := GetOrder('Chicken', 15, 10);
            2: Price := GetOrder('Fish', 12, 7);
            3: Price := GetOrder('Meat', 18, 8);
            4: Price := GetOrder('Salad', 5, 2);
            5: Price := GetOrder('Orange juice', 2, 1);
            6: Price := GetOrder('Milk', 1, 1);
            x, X: Writeln(Thanks);
            else
            begin
                Writeln('Wrong entry');
                Price:= 0;
            end;
        end;

        Total := Total + Price;
    until (Selection = 'x') or (Selection = 'X');
    Writeln('Total price                   = ',Total);
    Write('Press enter key to close');
    Readln;
end.