Computer Science Canada Tire Service Program, Need help with coding |
Author: | Da_Big_Ticket [ Tue May 24, 2005 8:58 pm ] |
Post subject: | Tire Service Program, Need help with coding |
In this program the user is required to imput information in order to come up with a bill. I realize this will be simple to you guys, but it will be a great help to me as i am stuck and the teacher i have dosent explain things. 1) A list is given of the tires offered at the store and the prices of each 2) The user selects which tire they want, the brand of tire must have its price attached with it somehow for later use 3) The user says how many tires they'd like, 4 gets them a discount of 20% on the tire cost only 4) They are required to enter y/n to wheter they want mounting, balancing, alignment, disposal, which all have costs associated with them 5) Taxes are to be included 6) A total bill is presented Thanks again guys, can you help me out please help is needed greatly! |
Author: | jamonathin [ Tue May 24, 2005 9:18 pm ] | ||
Post subject: | |||
Here's what you should start off with.
Now all you have to do is get how many tires they want; multiply that by their individual price, and if the amount is 4 then take off 20%. [ Hint, get the tire_type, then multiply the price (tire_type) by however many tires you have] Now for all that mounting and whatnot, just do the same thing as the tires, put them in matching array and have the cost added on. I don't really know what all that stuff is (alignment, disposal, . . .) Now just multiply everything by the 1.15% tax and show them what they baught in a reciept. |
Author: | Da_Big_Ticket [ Tue May 24, 2005 9:31 pm ] |
Post subject: | |
oh god, i havent even used that array stuff to even know what it does, is there any way to do it like: Font.Draw ("Time to select which tires you'd like, please type which brand you'd like from our selection.", 0, 340, questionfont, green) Font.Draw ("Tire Makes (individual prices): Bridgestone: $100, Goodyear: $130, Michelin: $160.", 15, 320, questionfont, green) locate (7, 3) get brand if brand = "bridgestone" then price := 100 elsif brand = "goodyear" then price := 130 elsif brand = "Michelin" then price := 160 Font.Draw ("How many tires would you like to purchase, 4 gets you a 20% discount", 15, 270, questionfont, green) locate (10, 3) get numberoftires or anything, im really worried because the teacher has not explained this at all to us, it is our first time using the program, and im takin it again next year |
Author: | Da_Big_Ticket [ Wed May 25, 2005 5:10 pm ] | ||
Post subject: | |||
This is what I have so far, can someone help fiill in the holes to make it work and explain any error in my coding. This is the main step as i later have to add code to figure out mounting/balance/alignment/tire disposal etc |
Author: | Paul [ Wed May 25, 2005 5:23 pm ] | ||
Post subject: | |||
roughly done, i gotta go:
|
Author: | Da_Big_Ticket [ Wed May 25, 2005 5:34 pm ] |
Post subject: | |
thanks ALOT man. I will pack back everyone somehow |
Author: | wtd [ Wed May 25, 2005 5:37 pm ] | ||||||||
Post subject: | |||||||||
jamonathin wrote: Here's what you should start off with.
He'd be far better off going with an array of records approach. A record is a compound data type. This means that it's a piece of data which is really composed of two or more pieces of data. In this case the two pieces of related data are the name of the brand and the price. By combining them in a record we make them inseparable. They can't get confused or mixed up.
Now, we have three brands of tires, so we need to store multiple records. This calls for an array.
Thn we can initialize the array like so:
|
Author: | Da_Big_Ticket [ Wed May 25, 2005 6:03 pm ] |
Post subject: | |
ok im starting to see what you are getting at, its just im not knowledgable about this program enough to fully understand that wtd. I really appreciate your help though, its good to know people arent self centerd on this site and are willing to put time into other peoples issues. |
Author: | wtd [ Wed May 25, 2005 6:15 pm ] | ||||||||||||||||
Post subject: | |||||||||||||||||
Now you present the user with three choices (the different brands) and ask for a number (1, 2 or 3) in response. Clearly, if it's anything other than one of those it's invalid and we have to ask again. So, potentially we have a loop.
Now, we need to prompt for a choice:
And, we need to output the brand name and price of each option. Fortunately, we have that bit of info already. We can loop over that array to output this information.
Inside the "for" loop, what should we do? Well, we wantto output the number, the name, and the price.
Now, we need to get an integer. We'll need an integer variable.
Now, we need to get an integer from the user.
Now, if the choice is one of the ones we approve, we need to exit the loop. That way the question won't be asked again.
Now, I know the user's choice is a valid one. Presuming, I'ved gotten the number of tires from the user, I can simply use the number the user input for their choice to look up the right price in the array.
|
Author: | Da_Big_Ticket [ Wed May 25, 2005 6:39 pm ] | ||
Post subject: | |||
alright, this is what ive got so far, now i just need to add in the mounting, balance, tire disposal etc
|
Author: | wtd [ Wed May 25, 2005 6:44 pm ] | ||
Post subject: | |||
For the love of everything sweet and decent please use indentation. Also, please remove the pointless comments. Comments should tell you something about what's going on that the code itself doesn't.
I know that keeps the screen open for 4 second, thenclears it. If you have to use a comment, use the comment to tell me why you're doing that. Also a general suggestion: get the core of the program down before you fiddle with pictures and fonts and what not. You don't know what arrays or records are and you're cluttering your code with mage loading code and what not? That's insane. |
Author: | Da_Big_Ticket [ Wed May 25, 2005 7:14 pm ] | ||
Post subject: | |||
|