Write a complete C++ program. The Mathematics department of Durham High school w
ID: 3614519 • Letter: W
Question
Write a complete C++ program.The Mathematics department of Durham High school wants a programdeveloped that will illustrate basic probability for their studentsin a fun way. In particular they want a program called "LittleLotto" that stimulates a lottery. In this program students canspecify the number of numbers in the selection set (1-12) and thenumber of numbers patrons must pick and match to the winningnumbers (between 1 and size of the selection set). It will reportthe patron's chance of winning as both a number and aprobability.
________________________________________________________________________________
Example output:
This program will tell you the probabilty of winning " LittleLotto".
How many numbers (1-12) are there to pick from? 12
How many numbers must you pick to play? 5
Your chance of winning the lottery is 1 chance in 793.
This is a probabilty of 0.0013.
_____________________________________________________________________________
a. Write a function to compute the number of ways a set of k itemscan be selected from a set of n items (n >= k). The functionprototype is given as the following:
int computeways (int n, int k);
Hint: n = n(n-1)(n-2).....(n-k+1) calculate in factorial n! / k! (n-k)!
_________________
k 1(2)(3)......(k)
b. Write a main function that ask user to specify n and k, and telluser the chance of winning as both a number and probabilty.
Here is my code
#include "stdafx.h"
#include <iostream>
using namespace std;
int factorial (int n)
{
if (n == 0)
return1;
else
return n *factorial (n-1);
}
int main ()
{
(factorial (n - k)) /((factorial (n));
}
Explanation / Answer
please rate - thanks #include #include using namespace std; int factorial (int); int computeways(int,int); int main () {int n,k,ways; double percent; coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.