{
cout << ” (this is NOT a palindrome)\n”;
}
}
return 0;
}
/*——————————————————————-*/
/*——————————————————————-*/
/* This function returns a value of true if string is a palindrome. */
–end;
}
return(is_pal);
}
/*——————————————————————-*/
/*——————————————————————–*/
/* Program chapter7_33 */
const int BUFFERSIZE = 180;
int main()
{
// Declare objects.
char buffer[BUFFERSIZE], new_string[BUFFERSIZE], filename[50];
int count;
// While not end of file, process string.
while(!palindromes.eof())
{
count = 0;
for(int k=0; k<strlen(buffer); ++k)
{
if(isalnum(buffer[k]))
{
}
// Input next string.
palindromes.getline(buffer, BUFFERSIZE);
}
return 0;
}
/*——————————————————————-*/
Calculating Probabilities
exit(1);
}
ranNumber=rand()%(theDeck.size());
Card aCard = theDeck[ranNumber]; //Draw card.
theDeck.erase(theDeck.begin()+ranNumber); //Remove card.
//Retain card for shuffle.
#include <cstdlib>
#include <vector>
#include “CardDeck8_15.h”
using namespace std;
int main()
{
myDeck.shuffleDeck();
//Draw two cards
card1=myDeck.randomDraw();
card2=myDeck.randomDraw();
}
}
cout << “Simulated results: ” << eventCounter << ‘/’ << n
<< ” = ” << eventCounter/n << endl;
/*——————————————————————–*/
/* Problem chapter7_35 */
/* */
/* This program tests a function that checks whether a deck is empty */
/* or not. */
//With the default constructor, the deck should be full
cout << “If the deck is empty, you should see a 1.\n”;
cout << “Is the deck empty? ” << myDeck.isEmpty() << endl;
//Empty the deck by drawing cards and see check again.
for (int i=52;i>0;i–) {
/* face cards in the hand. */
#include <iostream>
#include <cstdlib>
#include <vector>
#include “CardDeck.h”
card1.displayCard(cout);
cout << endl;
rank = card1.getRank();
if (rank>10){
switch(rank){
case 11:
}
/*——————————————————————–*/
/*——————————————————————–*/
/* Problem chapter7_37 */
/* */
/* This program uses the Card and CardDeck classes to deal a hand of */
/* 13 cards and estimate the probability of drawing a hand with no */
/* face cards in the hand. */
#include <iostream>
{
bool FaceCards;
cout << “Enter number of experiments to run “;
cin >> n;
for (int j=0;j<n;j++) {
//Shuffle the deck
return 0;
}
/*——————————————————————–*/
/*——————————————————————–*/
/* Problem chapter7_38 */
/* */
int main()
{
//Declare objects.
myDeck.shuffleDeck();
//draw 5 cards, check for kings and aces
for (int i=0;i<5;i++){
card1=myDeck.Draw();
myHand.push_back(card1);
if (aceCount==1 && kingCount==2){
eventCounter++;
//Display this winning hand.
for (int i=0;i<5;i++){
myHand[i].displayCard(cout);
return 0;
}
/*——————————————————————–*/
/*——————————————————————–*/
/* Problem chapter7_39 */
/* */
/* This program uses the Card and CardDeck classes to deal a hand of */
/* 5 cards and estimate the probability of drawing a hand with */
/* 2 pairs. */
int rank(0);
double eventCounter(0);
int n(0),pairs(0);
int counts[15]={0};
cout << “Enter number of experiments to run “;
}//end of hand drawing loop
//This checks for pairs and counts them
for (int k=2;k<15;k++){
if (counts[k]==2)
pairs++;
for (int i=0;i<15;i++)
counts[i]=0;
myHand.resize(0);
}//end of simulation loop
cout << “Simulated results: ” << eventCounter << ‘/’ << n
<< ” = ” << eventCounter/n << endl;
{
public:
//Constructor Function to initialize a data object
Line();
Line(Point, double);
Line(Point, Point, double);
double length;
Point fixedPoint;
Point secondPoint;
};
/************************************************************************/
/* Line class implementation (Line.cpp) */
#include “Line.h”
Line::Line(): length(1)
}
Line::Line(Point p, Point p2, double l)
{
fixedPoint = p;
secondPoint = p2;
length = l;
}
dx=p.getX()-fixedPoint.getX();
dy=p.getY()-fixedPoint.getY();
fixedPoint=p;
secondPoint.setX(secondPoint.getX()+dx);
secondPoint.setY(secondPoint.getY()+dy);
}
}
/************************************************************************/
/************************************************************************/
/* Line class Driver (chapter7_40.cpp) */
/* This is a sample driver program. */
#include <iostream>
#include “Line.h”
int main()
{
l2.printLine();
cout << endl;
l1.moveLine(p1);
cout << “New c1: “;
l3.resizeLine(10);
cout << “New c3: “;
l3.printLine();
cout << endl;
Point p3=l2.getFixedPoint();
Point p4=l2.getSecondPoint();
using namespace std;
class Circle
{
public:
//Constructor Function to initialize a data object
Circle();
Circle(double, double, double);
void resizeCircle(double);
private:
Point centerPoint;
double radius;
};
/************************************************************************/
{
centerPoint = p;
radius = l;
}
Point Circle::getCenterPoint() const
{
return centerPoint;
}
double Circle::getRadius() const
{
return;
}
void Circle::printCircle() const
{
cout << ‘(‘ << centerPoint.getX() << ‘,’ << centerPoint.getY()
<< “) R = ” << radius;
return;