Okay, first of all, I am *not* a programmer.
Sure, I grasp the basics, variables and equations and such. I really feel like I get what programming is about now-- solving problems. So, I figured the best way to learn and apply knowledge is to make myself a problem to solve. I am having a problem with a certain concept, I'm not sure what to use in this situation:
Pseudocode for my problem:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
Keeping up with a lemonade stand's business and profit.
How do I solve this problem?
1) define prices for each ingredient based on pounds
a) Two parts: Ingredient and price per pound.
1) Ingredient: Create "sugar" and "lemon_juice" types?.. basically categorize the variables in 2)
under sugar or lemonjuice..?
2) price per pound: Create "pound_cost" variable, and then APPLY "sugar" or "lemon_juice" to it:
ie: "sugar.pound_cost" or "lemon_juice.pound_cost"
also applicable as "pound_cost.sugar"
2) sum up a total price spent per serving, store in servingCost
The equation for this is sugar.pound_cost + (lemon_juice.pound_cost / 8)
3) define how much John is selling the lemonade for, store in grossProfit
(int grossProfit = 2.00)
4) grossProfit - servingCost = netProfit
5) Display output of
Cost per serving: servingCost
//Skip a line here
Selling the lemonade at: grossProfit
//Skip a line here
Total profit per cup: netProfit
|
How exactly would I go about declaring a "type"? Would I need to use classes for this? If not, what should I use to declare the variable sugar.pound_cost for example?
I'm not asking you to spoon-feed me the code for this (though that'd be helpful, I'd learn from it rather than just copypasting). I just need to know what to go research to make this concept effective.
And yeah I know, I could just declare separate variables for each one, but that wouldn't be stretching my limits would it?
Thanks in advance,
Nous
EDIT: just realized it'd be more code-efficient to flip 1A1 and 1A2 (pound_cost.sugar)