Hey this is Mohamed Shahabudeen. Can someone please help me with the following!


Enter the following program called “composers.pro

% This database is about composers
% Datarecords: composer’s last name, birth and death year

composer (monteverdi, 1567, 1643).
composer (bach, 1685, 1750).
composer (vivaldi, 1678, 1741).
composer (mozart, 1756, 1791).
composer (haydn, 1732, 1809).
composer (beethoven, 1770, 1827).
composer (kreisler, 1875, 1962).
composer (salieri, 1750, 1825).
composer (sammartini, 1700, 1775).
composer (scarlatti, 1660, 1725).
composer (schubert, 1797, 1828).
composer (schumann, 1810, 1856).
composer (tchaikovsky, 1840, 1893).
composer (brahms, 1833, 1897).
composer (verdi, 1813, 1901).
composer (debussy, 1862, 1918).
composer (stravinksy, 1882, 1971).
composer (wagner, 1813, 1883).
composer (chopin, 1810, 1849).
composer (corelli, 1653, 1713).
composer (copland, 1890, 1990).

% composer X is a contemporary of composer Y is the range of years during which they were alive overlap

contemporary (X,Y) :-

composer (X, B1, D1), composer (Y, B2, D2) , X \ = Y, overlap (B1, D1, B2, D2).

overlap (B1, D1, B2, D2). :- B2 >= B1, B2 =< D1.
overlap (B1, D1, B2, D2). :- B1 >= B2, B1 =< D2.

alive_during (Composer, Year) :-

composer (Composer, B1, D1), overlap (B1, D1, Year, Year).


a. Use the program to find all contemporaries of Bach, Verdi, and Copeland.

b. The Baroque era of classical music extends from 1600 to 1750. Write a predicate baroque/1, i.e., executed as baroque(X) where X is a particular name, that determines whether that composer belongs to the baroque era or not.) Prolog will answer “yes” or “no”. The predicate uses the database of composers shown above.

Thank you
Mohamed Shahabudeen

What language is this? Your post looks like homework.

the language is prolog. It is not homework but a brain teaser!

If you can help me, I would greatly be in gratitude.

What language is this? Your post looks like homework

Sorry, I can't help you because I don't know the first thing about that language. That would be pretty easy to write in other languages such as C, C++ or VB.

I Mohamed Shahabudeen will help someone grealtly if he/she helps me solve my Prolog problem below!

Enter the following program called "composers.pro"

% This database is about composers
% Datarecords: composer’s last name, birth and death year

composer (monteverdi, 1567, 1643).
composer (bach, 1685, 1750).
composer (vivaldi, 1678, 1741).
composer (mozart, 1756, 1791).
composer (haydn, 1732, 1809).
composer (beethoven, 1770, 1827).
composer (kreisler, 1875, 1962).
composer (salieri, 1750, 1825).
composer (sammartini, 1700, 1775).
composer (scarlatti, 1660, 1725).
composer (schubert, 1797, 1828).
composer (schumann, 1810, 1856).
composer (tchaikovsky, 1840, 1893).
composer (brahms, 1833, 1897).
composer (verdi, 1813, 1901).
composer (debussy, 1862, 1918).
composer (stravinksy, 1882, 1971).
composer (wagner, 1813, 1883).
composer (chopin, 1810, 1849).
composer (corelli, 1653, 1713).
composer (copland, 1890, 1990).

% composer X is a contemporary of composer Y is the range of years during which they were alive overlap

contemporary (X,Y) :-

composer (X, B1, D1), composer (Y, B2, D2) , X \ = Y, overlap (B1, D1, B2, D2).

overlap (B1, D1, B2, D2). :- B2 >= B1, B2 =< D1.
overlap (B1, D1, B2, D2). :- B1 >= B2, B1 =< D2.

alive_during (Composer, Year) :-

composer (Composer, B1, D1), overlap (B1, D1, Year, Year).

a. Use the program to find all contemporaries of Bach, Verdi, and Copeland.

b. The Baroque era of classical music extends from 1600 to 1750. Write a predicate baroque/1, i.e., executed as baroque(X) where X is a particular name, that determines whether that composer belongs to the baroque era or not.) Prolog will answer "yes" or "no". The predicate uses the database of composers shown above.

Thank you
Mohamed Shahabudeen

Instead of just begging someone to write your program for you why don't you try to do it and post what you have done, then ask specific questions about that you don't understand.

And stop posting the same question over and over and over and over ...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.