Qbasicnews.com

Full Version: This is the code.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I had to redo it a couple of times until I finally got it to work.


INPUT " DOLLAR AMOUNT OF SALE
=========================>", SALE.AMOUNT
INPUT " STATE SALES TAX IN % ==========================>", TAX
LET STATE.TAX = TAX / 100
LET TAX.AMOUNT = SALE.AMOUNT * STATE.TAX
LET TOTAL.AMOUNT = SALE.AMOUNT + TAX.AMOUNT
PRINT
PRINT
PRINT " THE SALE TAX AMOUNT IS =========================>", TAX.AMOUNT
PRINT " THE TOTAL SALE AMOUNT IS ======================>", TOTAL.AMOUNT
LPRINT " THE SALE TAX AMOUNT IS =========================>", TAX.AMOUNT
LPRINT " THE TOTAL SALE AMOUNT IS ======================>", TOTAL.AMOUNT
PRINT
Whats wrong with it, or do you just want us to see it. Be more specific
That code should work just fine. However:

1. You don't need to use LET at all. "LET a = 1" is the same as "a=1". It's much faster and, in my opinion, easier to follow if you leave the LETs out.

2. LPRINT may not work the way you want to unless you have a line printer. But I'm no expert on this. It might be better to send the results to a file:

OPEN "results.txt" FOR OUTPUT AS #1
PRINT #1, "THE SALE TAX AMOUNT IS =>"+STR$(TAX.AMOUNT)
PRINT #1, "THE TOTAL SALE AMOUNT IS =>"+STR$(TOTAL.AMOUNT)
CLOSE #1

3. You may find that your numbers are not rounding to two digits after the decimal point. To correct this, you either use math to round them, which I'll leave up to you, or you can use the "PRINT USING" command, which can be looked up in QB's help.

*peace*

Meg.
I he has a printer and runs that program a couple of times, indeed the printer would spit out a whole load of paper. :rotfl:

Tip: if you don't want this to happen, *don't* use LPRINT Smile. Just as Meg already said.
Code:
INPUT " DOLLAR AMOUNT OF SALE
=========================>", SALE.AMOUNT
INPUT " STATE SALES TAX IN % ==========================>", TAX
LET STATE.TAX = TAX / 100
LET TAX.AMOUNT = SALE.AMOUNT * STATE.TAX
LET TOTAL.AMOUNT = SALE.AMOUNT + TAX.AMOUNT
PRINT
PRINT
PRINT " THE SALE TAX AMOUNT IS =========================>", TAX.AMOUNT
PRINT " THE TOTAL SALE AMOUNT IS ======================>", TOTAL.AMOUNT
'LPRINT " THE SALE TAX AMOUNT IS =========================>", TAX.AMOUNT
'LPRINT " THE TOTAL SALE AMOUNT IS ======================>", TOTAL.AMOUNT
PRINT

That should do it =)
Code:
'***GET USER INPUT***
CLS
INPUT " DOLLAR AMOUNT OF SALE: ", SALE.AMOUNT
INPUT " STATE SALES TAX IN %: ", TAX

'***PERFORM CALCULATIONS***
STATE.TAX = TAX / 100
TAX.AMOUNT = SALE.AMOUNT * STATE.TAX
TOTAL.AMOUNT = SALE.AMOUNT + TAX.AMOUNT

'***OUTPUT TO SCREEN***
PRINT
PRINT
PRINT "THE SALE TAX AMOUNT IS", TAX.AMOUNT
PRINT " THE TOTAL SALE AMOUNT IS", TOTAL.AMOUNT

'***CREATE OUTPUT FILE***
OPEN "results.txt" FOR OUTPUT AS #1
  PRINT #1, "THE SALE TAX AMOUNT IS: "+STR$(TAX.AMOUNT)
  PRINT #1, "THE TOTAL SALE AMOUNT IS: "+STR$(TOTAL.AMOUNT)
CLOSE #1

'***PRINT OUTPUT FILE***
SHELL "copy results.txt > prn"

'***REMOVE OUTPUT FILE***
KILL "results.txt"

'***END THE PROGRAM***
SYSTEM

Somebody correct me if this doesn't work.

*peace*

Meg.
I was only posting it to let you all know that I did it.
As far as useing the LET command, that is the way the teacher want's us to do things for now....
:|

*gets out his hunting rifle*
Aga dont pull out any weapons. We have had a huge war with nuclear weapons and stuff and i think finally the thread was locked =)