Find the occupation and the score of each player

Assignment Help C/C++ Programming
Reference no: EM13976708

Question 1. Five golfers, named Jules, Gilles, Jean, Joe and Ghislain often play a round of golf together (use small caps for the players' names in your program). Their occupations are, not necessarily in this order, mason, plasterer, carpenter, tinsmith and roofer. They have played a round of golf but at the end their score cards don't match. Their results were even numbers between 64 and 84.

• Ghislain played par with 72, beating the roofer by 2 strokes.

• Gilles had a bad day, and has ended with 10 strokes above par, or 12 strokes more than the mason.

• The tinsmith has beaten Joe by 4 strokes and has won the round.

• Jules has beaten the carpenter by 8 strokes, but did not win overall.

Find the occupation and the score of each player.

a) Design a predicate to enumerate all possible combinations for players where N is the name of the player, O is the occupation and S is the score.

?- player(N,O,S).
N = jules,
O = carpenter,
S = 64;
N = jules,
O = carpenter,
S = 66
and so on.

b) Express the above bullet list as constraints, e.g., as below. You will have to fill-in the dots with the corresponding Prolog logic.
constraintRoofer(player(N,O,S)) :- ...
constraintMason(...
constraintTinsmith(...
constraintCarpenter(...
constraintWin(...

c) Finally, you will need to apply all the constraints, using the goal:

scores(player(jules,M1,P1), player(jean,M2,P2),
player(gilles,M3,P3), player(joe,M4,P4), player(ghislain,M5,P5)).

Question 2. We saw in class how to represent a binary search tree in Prolog. Write a predicate lca (K1, K2, T) which allows one to find the smallest common ancestor of K1 and K2 in the tree T. The predicate lca shall print the subtree T such that the root is the smallest common  ancestor of K1 and K2.

For example, given the tree
treeA (X):-X = t (73, t (31, t(5,nil,nil), nil), t (101, t (83, nil, t(97,nil,nil)), t(2016,nil,nil))).
We can issue the query

- treeA(X), lca(83,2016,X).
t(101,t(83,nil,t(97,nil,nil)),t(2016,nil,nil))
X = t(73, t(31, t(5, nil, nil), nil), t(101, t(83, nil, t(97, nil, nil)), t(2016, nil, nil))).

Reference no: EM13976708

Questions Cloud

How does media and sexual material influence a small child : What is CDA? Explain. What are the reasons behind the emergence of this act? Provide an analysis. How does media and sexual material influence a small child? Is transmitting sexual pictures or texting considered illegal? Why or why not
Assume that you just won the state lottery : Assume that you just won the state lottery. Your prize can be taken in the form of $40,000 at the end of each of the next 25 years or as a single amount of $500,000 paid immediately. If you expect to earn 7% annually on your investments over the next..
Using semi-annual compounding : Using semi-annual compounding, what is the price of a 5 percent coupon bond with 10 years left to maturity and a market interest rate of 7.2 percent? Assume that interest payments are paid semi-annually and that par value is $1000.
Expected return on the investment with a beta : The expected return on the S&P 500 is 10% and the risk-free rate is 3%. What is the expected return on the investment with a beta of (a) 0.2, (b) 0.5, and (c) 1.4?
Find the occupation and the score of each player : We saw in class how to represent a binary search tree in Prolog. Write a predicate lca (K1, K2, T) which allows one to find the smallest common ancestor of K1 and K2 in the tree T. The predicate lca shall print the subtree T such that the root is ..
Souvenir sheets cost the postal service : The postal service of St. Lucia, an island in the West Indies, obtains a significant portion of its revenues from sales of special souvenir sheets to stamp collectors.
Complete the pension work sheet : Using the above information for Marlin Corporation, complete the pension work sheet for 2015.
How much work does it take to bring them together : Two point charges Q1 = 3.9 μC and Q2 = 7.7 μC are initially very far apart. They are then brought together, with a final separation of 2.4 m. How much work does it take to bring them together?
Write function displayscorethat write score underneath : Write a function displayScorethat writes a score underneath the target. Give it suitable parameters. You can use turtle.write() to display information on the turtle canvas.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd