Prompt is to create a menu driven function where the user can choose from making a square or generating lottery numbers or exit the program
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
// Declare the variables
int choice;
//Set up the menu selections
cout << "Make a selection \n";
cout << "1. Print a hollow square \n";
cout << "2. Lottery drawing \n";
cout << "3. Exit \n \n";
cin >> choice;
// Declare the variables for the square
int size;
int row = 1;
int column = 1;
// variables for lottery drawing
int rand_int(int min, int max);
unsigned int even = 0, first_ball, second_ball, third_ball;
int number_drawings = 0, drawing_request = 0;
// Set up the selection for the menu
switch (choice)
{
case 1:
cout << "\n \n Enter the size for square: ";
cin >> size;
// Setting the square
while (row <= size)
{
while (column <= size)
{
if (row == 1 or row == size or column == 1 or column == size)
cout << "*";
else
cout << " ";
column++;
}
cout << endl;
row++;
column = 1;
}
break;
case 2:
// Setting up the generator
void lottery();
{
// User input the number of desired drawings
cout << "How many drawing would you wish? ";
cin >> drawing_request;
// Loop for the user input a number zero or less
while (drawing_request <= 0)
{
cout << "Please input a number that is greater than zero.";
cout << "\n \n How many drawing would you wish?";
cin >> drawing_request;
}
// Loop for the random generation of the lottery numbers
while (number_drawings < drawing_request)
{
number_drawings++;
// ball one drawing
first_ball = rand_int(1, 10);
// ball two of the drawing
do
second_ball = rand_int(1, 10);
while (second_ball == first_ball);
//drawing for third ball
do
third_ball = rand_int(1, 10);
while ((second_ball = third_ball) || (first_ball = third_ball));
// the percent of the numbers will come out even
cout << "\n Percentage that the lottery numbers will contain three even numbers: " << 100.0*even / number_drawings << endl;
}
break;
case 3:
// Exit the menu
cout << "\n \n Good Bye!";
break;