Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i need help in my project it is about a restaurant system the code should be written in prolog language (fact , rules , query)

i need help in my project it is about a restaurant system the code should be written in prolog language (fact , rules , query)

i wrote this code but it has an error i don't know where is the problem i need fixing for my code please modify the following so it matches the following requirement:

the idea of the program depends on providing a varied list of good fast food meals. for example. burger meals and pizza meals for the user, in addition, providing a feature for making suggestions which recommends a meal to user based on user preferences. such as the system will ask the user some questions and based on the user answers the system will suggest to the user a meal.

also I need at least 8 queries

% Define facts for food options

food_type(burger).

food_type(pizza).

topping(cheese).

topping(mushrooms).

topping(onions).

topping(pepperoni).

size(small).

size(medium).

size(large).

side(fries).

side(salad).

side(onion_rings).

substitution(no).

substitution(yes).

drink(no).

drink(yes).

dessert(no).

dessert(yes).

% Define rules for meal suggestions

suggest_meal(FoodType, Toppings, Size, Sides, Substitutions, Drink, Dessert, Meal) :-

food_type(FoodType),

member(Toppings, [cheese, mushrooms, onions, pepperoni]),

size(Size),

member(Sides, [fries, salad, onion_rings]),

substitution(Substitutions),

drink(Drink),

dessert(Dessert),

Meal = "Special " + FoodType + " with " + Toppings + ", " + Size + " size, " + Sides + ", " + Substitutions + " substitutions, " + Drink + " drink, and " + Dessert + " dessert.".

% Define queries for user input

ask_food_type :-

write("What type of food would you like to order? (burger/pizza)"),

read(FoodType),

assert(food_type(FoodType)).

ask_toppings :-

write("Would you like to add any toppings? (yeso)"),

read(Toppings),

assert(topping(Toppings)).

ask_size :-

write("What size would you like your meal to be? (small/medium/large)"),

read(Size),

assert(size(Size)).

ask_sides :-

write("Would you like any sides with your meal? (fries/salad/onion rings)"),

read(Sides),

assert(side(Sides)).

ask_substitutions :-

write("Would you like to make any substitutions in your meal? (yeso)"),

read(Substitutions),

assert(substitution(Substitutions)).

ask_drink :-

write("Would you like to add a drink to your order? (yeso)"),

read(Drink),

assert(drink(Drink)).

ask_dessert :-

write("Would you like to add a dessert to your order? (yeso)"),

read(Dessert),

assert(dessert(Dessert)).

% Suggest meal based on user input

suggest_order :-

ask_food_type,

ask_toppings,

ask_size,

ask_sides,

ask_substitutions,

ask_drink,

ask_dessert,

suggest_meal(FoodType, Toppings, Size, Sides, Substitutions, Drink, Dessert, Meal),

write("Based on your choices, we suggest the following meal: "),

write(Meal), nl,

write("Would you like to order this meal? (yeso)"),

read(Order),

(

(Order == yes)

-> write("Thank you for your order!")

; write("Okay, let's try again.")

).

The error :

image text in transcribed

SWISH File Edit v Examples v Help v Singleton variables: [FoodType, Toppings, Size, Sides, Substitutions, Drink, Dessert] ic Singleton variables: [FoodType, Toppings, Size, Sides, Substitutions, Drink, Dessert] ask_dessert, [3] assert(food_type(pizza)) suggest_meal(FoodType, Toppings, Size, Sides, Substitutions, Drink, Des [1] suggest_order at if line 76 write("Would you like to order this meal? (yeso)"), ?- suggest_order

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications Dexa 2023 Workshops 34th International Conference Dexa 2023 Penang Malaysia August 28 30 2023 Proceedings

Authors: Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil ,Bernhard Moser ,Atif Mashkoor ,Johannes Sametinger ,Maqbool Khan

1st Edition

ISBN: 303139688X, 978-3031396885

Students also viewed these Databases questions

Question

Have you ever been arrested for a crime?

Answered: 1 week ago