----------------------------------- AiR Tue May 25, 2004 6:47 pm Computer Store with turing ----------------------------------- For a school project I have to make a program which is a store that sells anything I want since I am already selling computer mods I decided to use those. I am having a problem at getting the tax if some of you may help me, it would be appreciated. Also please give comments on how I can improve this program. var password := 0214 var stock1, stock2, stock3, stock4, stock5 := 20 var answer, choice : string var cart := 0 var quantity : int var colr : int := 32 var money, change : int var tax:= cart *.15 loop loop loop colorback (white) cls color (black) put " " put "Please enter password." color (white) get password color (black) if password not= 0214 then put " " put "That is incorrect access is denied. " elsif password = 0214 then exit end if end loop put " " put "Welcome to Brightling, one of the world's top seller in computer modifications." loop put " " put "Would you like to purchase an item(s) Yes cart := cart + tax Can't seem to get this going change := money - cart put "Your total change change will be ", change end if end loop end loop Also in addition I would like to add if the stock = 0 I would tell them the product is sold out. ----------------------------------- Cervantes Tue May 25, 2004 7:03 pm ----------------------------------- change this line cart := cart + tax to this cart := cart + round (tax) and it should work. previously you were trying to add a real number (tax) to an integer (cart) and it wouldn't let you. I haven't looked through all of your code, but I do have one comment: where you have this: if answer = "No" or answer = "no" or answer = "N" or answer = "n" then put "Good bye have a nice day." loop end loop I'm not sure if you really want to contain the user in an infinate loop of nothingness, but you may consider replacing loop end loop with quit as for telling the user that the product is sold out, just have a few if statements in this part of the code put "Which item(s) would you like to purchase? " put "a) Cathode Lights / Stock:", stock1, " / Price: $20" put "b) Computer Cases / Stock:", stock2, " / Price: $200" put "c) Fan Grills / Stock:", stock3, " / Price: $20" put "d) Lazer LED Lights / Stock:", stock4, " / Price: $30" put "e) Window Appliques / stock:", stock5, " / Price: $10" to determine whether stock = 0 and if it is then instead of writing something like up there ^, put "item sold out" or whatever you want. ----------------------------------- Tony Wed May 26, 2004 8:28 am ----------------------------------- the problem with the code is that everything is hardcoded (including passwords, items and stock). It would be diffucult to add another item to the list since if statements and tables must be modified (and new variables created) If you are familiar with arrays, you should defenatly try to run the program with a datafile to contain product listing and stock available. ----------------------------------- the_short1 Wed May 26, 2004 8:16 pm ----------------------------------- yea arrays would be better.... also i notice at top... u have var cart : int := 0 var tax :int := cart * .15 i would have that as var tax : int := 0.15 because as it was.... cart was = 0 and .15 * 0 = 0 then ur tax will be nothing!!! at the end of ur program.. use this: cart := round (cart * .15) havng it this will add tax to the cart cost.. and round to nearest DOLAR.... having it cervants way will round .15 and that would be 0*cart... then ur cart will be NOTHING.. . hope that clears things up!!.. ----------------------------------- Tony Wed May 26, 2004 10:59 pm ----------------------------------- the_short1: var cart := 0 var tax:= cart *.15 notice the lack of :int? :P even though the tax is 0, it gets promoted to a real type variable because of that *. though it could have as easily be decleared as var tax := 0.0 ----------------------------------- the_short1 Thu May 27, 2004 7:01 am ----------------------------------- whoopz... i though i edited afta i posted and added them in...... guess not... did u add for me... thx either way the point was made.. ----------------------------------- AiR Mon May 31, 2004 12:46 am ----------------------------------- Wow I really appreciate all your help on the tax guys, I finally got it working. I was afraid to post here before because I saw how some of you treat other newbies. Heres an updated version. When I ask them if they want to select another item once they say "yes" it gets directly out of the loop and gives the user the price of the items without ever letting him pick another item. var password := 0214 var stock1, stock2, stock3, stock4, stock5 := 20 var answer, choice : string var cart := 0 var quantity : int var colr : int := 32 var money : int var tax := .15 loop loop loop colorback (white) cls color (black) put " " put "Please enter password." color (white) get password color (black) if password not= 0214 then put " " put "That is incorrect access is denied. " elsif password = 0214 then exit end if end loop put " " put "Welcome to Brightling, one of the world's top seller in computer modifications." loop put " " put "Would you like to purchase an item(s) Yes ----------------------------------- Tony Mon May 31, 2004 1:02 am ----------------------------------- I saw how some of you treat other newbies. haha, some newbs get it harsh when they post asking something along the lines of "i can't make (something complex that is most likely a project), give me code" and they post such in a wrong forum too :roll: you on other hand had most of the program done and knew exactly what you had problems with :) we're always glad to have members such as you AiR and I hope you'll enjoy your stay @ compsci :D