Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Define and test the Prolog predicates described below. Each of your predicates must have the same name and signature as the examples below . Your

Define and test the Prolog predicates described below. Each of your predicates must have the same name and signature as the examples below. Your predicates must behave properly on all instances of valid input types. Your submission should consist of a single source code text file that includes all facts, predicate definitions, and propositions.

You may find additional Prolog language help at the following links:

SWI-Prolog manual: http://www.swi-prolog.org/pldoc/refman/

SWI-Prolog documentation: http://www.swi-prolog.org/pldoc/index.html

Learn Prolog Now: http://www.learnprolognow.org/

1) Odd Multiple of 3

Define a predicate oddMultOf3/1 that determines whether an integer is an odd multiple

of 3. A user should be able to enter the predicate with an integer, e.g. oddMultOf3(42)

and evaluate to either true or false. If the given parameter is not an integer, your

predicate should display the message ERROR: The given parameter is not an

integer.

Input/Output:

?- oddMultOf3(171).

true.

?- oddMultOf3(100).

false.

?- oddMultOf3(12).

false.

?- oddMultOf3(4.2).

ERROR: The given parameter is not an integer

?- oddMultOf3(-9).

true.

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

Practical Oracle8I Building Efficient Databases

Authors: Jonathan Lewis

1st Edition

0201715848, 978-0201715842

More Books

Students also viewed these Databases questions