One way to begin attacking a problem is to just start writing down obvious (update: even rather trivial) elements of the problem and general relationships between those elements. Even if it doesn't seem immediately relevant, just write it down. As you begin to see more relationships, write those down (or at least keep them in mind). AnonyMonk has started the process here.
What else springs to mind?
-
If each pizza has a cost and you make a certain number of them, what's the total cost?
my $total_cost = $cost ... $sold ...;
-
If you're actually selling each pizza at a discounted price, what is that price?
my $discounted_price = $price ... $discount ...;
-
If you sell a certain number of pizzas at the discounted price, what are your total sales?
my $total_sales = $discounted_price ... $sold ...;
-
What's your profit?
my $profit = $total_sales ... $total_cost ...;
So you might end up with an outline of general relationships like this:
#!/usr/bin/perl
use strict;
use warnings;
my $sold = 10;
my $cost = 250;
my $price = 300;
my $discount = 0.10;
my $total_cost = $cost ... $sold ...;
my $discounted_price = $price ... $discount ...;
my $total_sales = $discounted_price ... $sold ...;
my $profit = $total_sales ... $total_cost ...;
Again, as long as they're true, don't worry if some of the statements don't seem immediately relevant or useful; it's easy to delete text. Work on refining relationships that seem useful: exactly what is the relationship of the total cost to the per-item cost and the total made or sold? Continue on to a solution!
Give a man a fish: <%-{-{-{-<
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|