StartprogrammingusingObjectPascal:RestaurantProgramUsingFunctions: Difference between revisions
Jump to navigation
Jump to search
Onionmixer (talk | contribs) (오류수정) |
Onionmixer (talk | contribs) (오류수정) |
||
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 | Writeln('1 - Chicken (10$)'); | ||
Writeln('2 | Writeln('2 - Fish (7$)'); | ||
Writeln('3 | Writeln('3 - Meat (8$)'); | ||
Writeln('4 - Salad (2$)'); | Writeln('4 - Salad (2$)'); | ||
Writeln('5 - Orange Juice (1$)'); | Writeln('5 - Orange Juice (1$)'); | ||
Writeln('6 | Writeln('6 - Milk (1$)'); | ||
Writeln; | Writeln; | ||
end; | end; |
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.