StartprogrammingusingObjectPascal:RestaurantProgramUsingIfCondition

From 흡혈양파의 번역工房
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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 등급으로 변환해줍니다.