Computer Science Canada Grocery Problem |
Author: | Jurica [ Tue Nov 04, 2008 7:02 pm ] |
Post subject: | Grocery Problem |
I have a problem with this question I have to do. I've tried everything I know, I am a beginner so please don't make fun of me like "Oh your so stupid". Question: Write a program that accepts the name of an item and the price. Have the program calculate a sales price that includes a 10% discount. Print a sales receipt on the screen with the name of the item, the sales price, the GST and PST and the total price. (Be sure to round-off to 2 decimal places) var total : real := 0 var product : int loop put "Welcome to my Grocery Store!" put "Enter product (1=Corn, 2=Potatoes, 3=Artichokes, 4=Quit): ".. get product if product = 1 then total := total + 2.25 - 0.18 elsif product = 2 then total := total + 6.50 - 0.18 elsif product = 3 then total := total + 1.75 - 0.18 elsif product = 4 then exit end if put "The running total is $", total : 0:2 end loop put "10% Discount: $", total * 0.10 : 0:2 put "GST: $", total * 0.08 : 0:2 put "PST: $", total * 0.06 : 0:2 put "--------------------------" put "Final Total: $", total * 1.14 : 0:2 |
Author: | jbking [ Tue Nov 04, 2008 7:22 pm ] |
Post subject: | RE:Grocery Problem |
A few questions if you don't mind: 1) Why not let the user enter a string for the name of the product? This would be a bit easier on the user I think. 2) Why not let the user enter a quantity along with the price, e.g. they can buy 3 widgets @ $3.30 or whatever. 3) What is with subtracting .18 so often? I'm just wondering on this as it doesn't quite make sense to me. 4) Why not change the total on some of the lines near the end so that the discount is taken into account as the way it is written now, it doesn't really do that. Also, you aren't compounding the discount and taxes I think. For example, if you take a product that costs $100 and give a 10% discount and then add a 10% tax on it, what is the end result? Answer: $99 which isn't necessarily what some would know. |
Author: | Geniis [ Tue Nov 04, 2008 9:28 pm ] | ||
Post subject: | Re: Grocery Problem | ||
Dont worry no one here will laugh at you.. everyone is a beginner at some point right?(im still a beginer myself ive only know turing for like 2 months lol) Anyway with your problem i think you should do sumthing like this:
Not to complicating. Try keeping most of your numbers and stuff inside of variables and constants, makes it easier to read your program (as long as the variable name isnt completely random lol) That should solve your probleme |
Author: | Jurica [ Wed Nov 05, 2008 4:47 pm ] | ||
Post subject: | Re: Grocery Problem | ||
Geniis @ Tue Nov 04, 2008 9:28 pm wrote: Dont worry no one here will laugh at you.. everyone is a beginner at some point right?(im still a beginer myself ive only know turing for like 2 months lol)
Anyway with your problem i think you should do sumthing like this:
Not to complicating. Try keeping most of your numbers and stuff inside of variables and constants, makes it easier to read your program (as long as the variable name isnt completely random lol) That should solve your probleme Thank you, this was fixed my problem. |
Author: | syntax_error [ Wed Nov 05, 2008 9:38 pm ] |
Post subject: | Re: Grocery Problem |
Jurica @ Wed Nov 05, 2008 4:47 pm wrote: Thank you, this was fixed my problem. How? Jurica simply gave away the answer, I do not mean to sound like a prick; however, try reading over the forum rules? Posting full solutions does not help the person. Furthermore, its frowned upon. |
Author: | Jurica [ Thu Nov 06, 2008 1:21 pm ] |
Post subject: | Re: Grocery Problem |
syntax_error @ Wed Nov 05, 2008 9:38 pm wrote: Jurica @ Wed Nov 05, 2008 4:47 pm wrote: Thank you, this was fixed my problem. How? Jurica simply gave away the answer, I do not mean to sound like a prick; however, try reading over the forum rules? Posting full solutions does not help the person. Furthermore, its frowned upon. I know he posted the whole thing, but I already did like 75% of the question probably more. He just helped the rest I needed help with. But I don't really understand the rules, this is in 'Turing Help' section, but you can't help him fully. That's kind of gay. |
Author: | Euphoracle [ Thu Nov 06, 2008 3:33 pm ] |
Post subject: | RE:Grocery Problem |
No, it's not a sexuality, and it makes perfect sense, because you learn nothing. |
Author: | Jurica [ Thu Nov 06, 2008 3:55 pm ] |
Post subject: | Re: RE:Grocery Problem |
Euphoracle @ Thu Nov 06, 2008 3:33 pm wrote: No, it's not a sexuality, and it makes perfect sense, because you learn nothing.
I don't mean gay as in Homosexual, and it doesn't really because if I need help people help me, they may be giving me the whole answer but I did most of the question I just needed help with a couple of things, and I do learn something. I didn't just copy and paste the solution and pasted it and handed my work. I went through it and read it so next time I need to do something like that again I'll know what to do, so I basically do learn. And why would they make a 'Turing Help' page if you're not even aloud to really help them? |
Author: | jbking [ Thu Nov 06, 2008 4:00 pm ] |
Post subject: | RE:Grocery Problem |
The question is what kind of help to give: If the whole answer is given, some may learn and some may not learn from it. Usually there are ways to suggest various ways to try to solve the problem so that the methodology is transferred but not everyone can get that. It would be one thing if this was called "Turing Solutions" but it isn't. |
Author: | Jurica [ Thu Nov 06, 2008 4:09 pm ] |
Post subject: | RE:Grocery Problem |
I know he gave the whole solution but I asked to help me with a couple of things, he just used my answers that I've posted changed it a bit to put the stuff I asked. This isn't supposed to help other people it's for me, I asked him. |
Author: | Geniis [ Thu Nov 06, 2008 4:19 pm ] |
Post subject: | Re: Grocery Problem |
sorry i didnt want to give him the entire thing but i didnt know how else to help.. what i posted was only supposed to give him a general idea of what to do... I guess before i help someone i should make sure i know how to explain things first eh? lol |
Author: | Jurica [ Thu Nov 06, 2008 4:21 pm ] |
Post subject: | RE:Grocery Problem |
Lol, true. But thanks anyways. |