It is the final of the world’s most prestigious cricket tournament, the Indian Premier League. In the final, the Chennai Super Kings [CSK] are playing against the Mumbai Indians [MI]. There is one over left for the match to end and CSK require R runs to win with W wickets remaining.
An over consists of 6 balls. Each ball can result in any one of the following possibilities:-
- 6 Runs
- 4 Runs
- 7 Runs [3 Runs + Overthrows]
- 2 Runs
- 1 Run
- Wicket
If a ball results in a wicket, CSK’s remaining wickets will decrease by one. If a ball results in runs [either 6, 4, 7, 2 or 1], these runs are added to the runs that CSK have already scored.
The match ends when one of the following happens:-
* If CSK scores R runs, the match ends and CSK wins.
* If the match ends with CSK scoring exactly one run less than the required runs, then the match is a tie.
A ticket selling booth in a cricket stadium, people has to buy the ticket from this booth to enter into the stadium. Price of the each ticket is Rs. 500. The booth keeps track of the number of people visited the stadium. Model this ticketing booth with a class called Counter A including following members Data members [i] Number of people visited [ii] Total amount money collected Member functions [i] To assign initial value [ii] To increment people total as well as amount total if a ticket is sold out. [iii] To display two totals Write a program to test this class.
#include
using namespace std;
class CounterA{
private:
//members Data members
//[i] Number of people visited
int numberPeopleVisited;
//[ii] Total amount money collected
float totalAmountMoneyCollected;
public:
//Member functions
//[i] To assign initial value
void assignValues[]{
this->numberPeopleVisited=0;
this->totalAmountMoneyCollected=0;
}
//[ii] To increment people total as well as amount total if a ticket is sold out.
void sellTicket[]{
this->numberPeopleVisited++;
// Price of the each ticket is Rs. 500.
this->totalAmountMoneyCollected+=500.0;
}
//[iii] To display two totals
void display[]{
cout