StartprogrammingusingObjectPascal:RestaurantProgramUsingIfCondition: Difference between revisions

From 흡혈양파의 번역工房
Jump to navigation Jump to search
(예제수정)
(소스코드 수정)
 
Line 6: Line 6:
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;
     Write('Please enter your selection: ');
     Write('Please enter your selection: ');

Latest revision as of 11:34, 4 April 2013

if 조건문을 사용한 레스토랑 프로그램

var
    Meal: Byte;
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;
    Write('Please enter your selection: ');
    Readln(Meal);

    if Meal = 1 then
        Writeln('You have ordered Chicken, this will take 15 minutes')
    else
    if Meal = 2 then
        Writeln('You have ordered Fish, this will take 12 minutes')
    else
    if Meal = 3 then
        Writeln('You have ordered meat, this will take 18 minutes')
    else
    if Meal = 4 then
        Writeln('You have ordered Salad, this will take 5 minutes')
    else
    if Meal = 5 then
        Writeln('You have ordered Orange juice,' ,
            ' this will take 2 minutes')
    else
    if Meal = 6 then
        Writeln('You have ordered Milk, this will take 1 minute')
    else
        Writeln('Wrong entry');
    end;

    Write('Press enter key to close');
    Readln;
end.


다음 예제에서는, 프로그램이 학생들의 성적을 계산해서 A 그리고 B, C, D, E, F 등급으로 변환해줍니다.