View Full Version : Qbasic help
mikes4x4
04-08-2006, 01:06 PM
Slowly learning Qbasic; need help setting this up in Qbasic
Pricing code A, B, C, D, F,
Discount code 50%, 40%, 33%, 25%, 0%
Thanks in advance
wheelchair_mike
Steven Edwards
04-08-2006, 01:14 PM
Can you give a few more details about the project?
mikes4x4
04-08-2006, 02:23 PM
I am to design an algorithim that will prompt a operator for the price of an article and a pricing code. my program is then to calculate a discount rate accotding to the pricing code and print to the screen the original price of the article, the discount amount and the new discount price. Calculate the pricing code and accompanying discount amount as follows:
Pricing code A, B, C, D, F,
Discount code 50%, 40%, 33%, 25%, 0%
thanks
mike
mikes4x4
04-08-2006, 02:27 PM
the file
0 CLS
20 PRINT "New Discount Price"
30 LET codeF = 0
40 LET codeT = 0
50 LET codeQ = 0
60 LET codeZ = 0
70 INPUT " Code H = : ", codeH
80 INPUT " Code F = : ", codeF
90 INPUT " Code T = : ", codeT
100 INPUT " Code Q = : ", codeQ
110 INPUT " Code Z = : ", codeZ
111 DO WHILE code
120 IF codeH = 1 THEN
130 ELSE
140 IF codeF = 2 THEN
150 ELSE
160 IF codeT = 3 THEN
170 ELSE
180 IF codeQ = 4 THEN
190 ELSE
200 IF codeZ = 5 THEN
210 END IF
220 END IF
230 END IF
240 END IF
250 END IF
251 LOOP
260 PRINT codeH; 50, codeF; 40, codeT; 33, codeQ; 25, codeZ; 0
270 END
Steven Edwards
04-08-2006, 03:03 PM
This (http://www.warebizprogramming.com/tutorials/qbasic/toc.htm) looks to be a good QBasic tutorial. My QBasic is a bit rusty, but you would want something like this (line #s omitted):
Dim iPrice as Double
Dim pCode as String
Let iPrice = 1.00
Print "Enter the item's price, followed by it's pricing code (A-D, F). Enter -1 for the price to end."
Do While (iPrice <> -1)
Input iPrice
Input pCode$
Select Case pCode$
Case "A"
Print "Original price: $"; iPrice
Print USING "Discount amount: $$######.##"; (iPrice*.50)
Print USING "Discount price: $$######.##"; (iPrice*(1-.50))
Case "B"
....
End Select
Loop
Print "Done!"
mikes4x4
04-22-2006, 02:16 PM
Thanks Steven....