Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Getting this error. [Error] expected ';' after class definition #include #include #include #include using namespace std; int sum=0; class Coin { int sideUp; public: Coin(int

Getting this error. [Error] expected ';' after class definition

#include

#include

#include

#include

using namespace std;

int sum=0;

class Coin

{

int sideUp;

public:

Coin(int value)

{

toss(value);

};

void toss(int value);

}

void Coin::toss(int value)

{

if(rand() %100<=50)

{

sum+=value;

cout<<" You got a head. Value "<

}

else

{

cout<<" You got a tail. No value added";

}

}

int main()

{

int temp;

cout<<" Quarter = 25 cents Dime = 10 cents Nickel = 5 cents ";

cout<<" If the final sum is 100 cents (1 dollar), you win. Else you lose!! All set to play the game?? Press enter when you are ready! ";

getch();

while(sum<100)

{

temp=rand() %100;

if(temp<=30)

{

Coin nickelObj(5);

}

else if(temp<=65)

{

Coin dimeObj(10);

}

else

{

Coin quarterObj(25);

}

}

cout<<" Total value added to the Sum = "<

if(sum==100)

cout<<" *** You win ***";

else cout<<" *** You lose ***";

getch();

return 0;

}

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

MFDBS 89 2nd Symposium On Mathematical Fundamentals Of Database Systems Visegrad Hungary June 26 30 1989 Proceedings

Authors: Janos Demetrovics ,Bernhard Thalheim

1989th Edition

3540512519, 978-3540512516

More Books

Students also viewed these Databases questions