Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Dear perl monks, For the past couple of day i have been working on a peice of code and now im stuck.

The task is to create a Swimming pool entrance fee calculator with given rates + group discount it also need to print the number in the group and the cost.

So far this is what i have but i really dont know what i neede to do to get it to work.
#!/usr/bin/perl use warnings; use strict; my $age; my $group; my $total; print "Cost: £5 if aged 15 or under £2.50, aged 60 or over £3.00, Grou +p Discounts are 20% off for groups of 6 or more."; print "How old are you? "; $age = <>; print "User age is $age"; print "How many people are there"; $group = <>; print "group number is $group"; $total = $group*

Replies are listed 'Best First'.
Re: Perl Programming help required
by marto (Cardinal) on Nov 14, 2010 at 10:19 UTC

    I think you need to think about this problem again before trying to solve it. You ask for one persons age, are you assuming that everyone in the group is the same age?

    Your interface seems flawed to me. Rather than enter each individuals age (which you don't do at the moment, so how can you possibly be charging the correct price?) why not simply prompt for how many kids, adults and over 60s there are, you'd then know the total number of people and the entry price, at which point if there are >= 6 people apply the discount.

    Now on to your code. You should read about chomping your input. If you're new to perl see:

    If you have any other problems let us know. Please don't ignore formatting advice given when composing posts. See How do I post a question effectively? and Writeup Formatting Tips.

Re: Perl Programming help required
by Anonymous Monk on Nov 14, 2010 at 09:56 UTC
    How you would solve the problem with pencil and paper? Please explain