I am coding in the dark due to the fact that I have Perl linked to textPad and every time I execute my code it only displays the print lines. It will not accept any input, textPad simply tells me "This is a read only document". So none of my STDIN's are working. I think that all my code works and fulfills all these requirements but can someone help me out
These are the requirementsProject 1
Create a program for printing lottery tickets
The program must have these features
1) Print a welcome screen
2) Ask the user for the # of tickets desired (1 thru 10)
3) Ask the user how many numbers on a ticket (e.g. 6)
4) Ask the user for the maximum of the number (e.g. 44)
5) Generate the #s using a random number generator
6) Print the lottery #s in a user friendly way
7) Thank the user for using your program.
The program must be user friendly and prompt the user for re-entering the input if there is an error in the input e.g. # of tickets > 10
The lottery numbers for a ticket must be unique though they can be repeated in other tickets.
CODE
#!/usr/bin/perl
$counter = 0;
print "Welcome to the lottery program!\n";
print "How many tickets would you like to purchase? (1 - 10): ";
chomp($tickets=<STDIN>);
print "\n";
print "\n";
do
{
if ($tickets > 10)
{
print "To many tickets, purchase 10 or fewer...";
chomp($tickets=<STDIN>);
}
}
while ($tickets > 10);
print "How many numbers will be on each of your tickets? ";
chomp($numbers=<STDIN>);
print "\n";
print "\n";
print "What is the maximum number for each ticket? ";
chomp($maximum=<STDIN>);
print "\n";
print "\n";
print "These are your lottery tickets\n";
do
{
my @numbers = (1..$maximum);
my $limit = $numbers;
my %list = ();
while (keys %list < $limit)
{
$list{$numbers[rand @numbers]}=1;
}
print join(' ', sort {$a <=> $b} keys %list);
print "\n";
$counter++;
}
while ($counter < $tickets);
print "\n";
print "\n";
print "The winning combination of lottery numbers is...";
my @numbers = (1..$maximum);
my $limit = $numbers;
my %list = ();
while (keys %list < $limit)
{
$list{$numbers[rand @numbers]}=1;
}
print join(' ', sort {$a <=> $b} keys %list);
print "\n";
print "Thank you for using the lottery program!\n";