more useful options | |
PerlMonks |
Re: Please Help! This is a class assignment given to me.by harangzsolt33 (Chaplain) |
on Dec 07, 2019 at 06:11 UTC ( [id://11109790]=note: print w/replies, xml ) | Need Help?? |
I dont know where to start or how to start
You should start with the math. Figure out what you want the program to calculate and how to calculate it. Once you get that straight, writing the perl script will be very easy. You want to find the profit. And you have 10 pizzas. Let's find the profit for one pizza first and then we multiply it by 10. Okay? The profit equals income - expense. Income is the price you get for the pizza, and expense is what you pay for the ingredients and cooking and labor, etc. In this case, figuring out the expense is easy, because we are told that the pizza price is 250. So, 250 includes all the expenses. The income is 300, because that's what you're selling it for. And the difference is 50. That's your profit. That's the question. But then what if you sell the pizza 10% cheaper? Now, instead of selling it for 300, you sell it for 270, because that's 10% less. Now, if you pay 250 for the pizza and sell it for 270, then you still have a profit of 20 on each pizza. So, the math is pretty simple... Yes, writing the perl code is also simple, but you have to figure it out yourself. Every perl program starts with the same three lines of code. And this is just to get you started: #!/usr/bin/perl -w
In programming languages, when you write A = 4, that's not a math equation. It's an instruction for the processor to store the value "4" in a memory location which we label as "A" If you want to do a multiplication, then you would do something like: A = 4 * 12; But in perl, every label or variable I should say is preceded by a $ sign. And you should declare the variable before you use it. That means the first time you assign a value to it, you should put the word "my" in front of it: my $A = 4; If you want to do multiplication in perl, you would do: my $A = 4 * 12;
When you multiply a value by something else, you can write it as : my $A = 2;
Hope that wasn't too confusing.
In Section
Seekers of Perl Wisdom
|
|