Thursday, November 25, 2010

Thursday- Finished Modified Number 12 and What a coincidence it's Mr.Arkin's Birthday!!

I believe this assignment was a great challenge and I actually enjoyed it, due to the feeling when one gets once they successfully complete a program. The feeling is indescribable and only a programmer would know what I am talking about. If I were to try my best and describe this feeling it would be the equivalent to losing 20 pounds in an instant. It makes one feel light and joyful, in my case it makes me want to jump, because when one know's they have accomplished something worth wile it makes them feel extraordinary. This is my first successful array program I have produced and it is only the foundation for more to come. 


Here it is! : 



% declaration section

const GST := 0.05
const PST := 0.08
const ARRAY_LIMIT := 100
const DELAY := 1000

var price : array 1 .. ARRAY_LIMIT of real
var priceIndex : int
var tax : array 1 .. ARRAY_LIMIT of int
var total : real
var tax_PST : real
var tax_GST : real
var sum : real
var taxIndex : int
var amount_of_items : int

% intialization section
priceIndex := 1
sum := 0
total := 0
tax_PST := 0
tax_GST := 0
taxIndex := 1
amount_of_items := 0

% input and processing section

loop

    colourback (black)

    cls

    colour (yellow)
    put "Tax status #", taxIndex, " (1/2) : "
    put "1 = Yes"
    put "2 = No"
    get tax (taxIndex)
    put "Price", priceIndex, " (enter 0 if want to stop) : $" ..
    get price (priceIndex)
    amount_of_items := amount_of_items + 1

    if tax (taxIndex) = 1 then

        sum := sum + price (priceIndex)
        tax_PST := sum * PST
        tax_GST := sum * GST
        total := tax_PST + tax_GST + sum

    elsif tax (taxIndex) = 2 then
        tax_PST := 0
        tax_GST := 0
        sum := sum + price (priceIndex)

    else

        put "Invalid tax status, please enter valid one! "
        delay (DELAY)

    end if
    taxIndex := taxIndex + 1
    exit when price (priceIndex) <= 0
    priceIndex := priceIndex + 1
end loop

%output

priceIndex := 1
taxIndex := 1

colourback (black)
cls
color (white)
put repeat ("=", 20)

put "Your Receipt"

loop

    put "Item ", priceIndex, " $", price (priceIndex) : 0 : 2

    if tax (taxIndex) = 1 then

        put " Taxable y"

    elsif tax (taxIndex) = 2 then

        put " Taxable n"

    else

        put "Taxable not specified"

    end if

    taxIndex := taxIndex + 1
    priceIndex := priceIndex + 1

    exit when priceIndex > amount_of_items - 1
    delay (DELAY)

end loop

put "Subtotal: $", sum : 0 : 2
delay (DELAY)
put "PST: $", tax_PST : 0 : 2
delay (DELAY)
put "GST: $", tax_PST : 0 : 2
delay (DELAY)
put "Total: $", total : 0 : 2
delay (DELAY)
put "Amount of items: ", amount_of_items - 1
delay (DELAY)
% extro

put repeat ("=", 20)

put "Thank you! "

put repeat ("-", 20)


  Please, if there is anything wrong with this program comment, I will appreciate the criticism and will do my best to fix all the errors. 
   Now I would also like to say Yom hew' led-it sam-e-ach, mar Arkin!(means happy birthday Mr.Arkin). Today was Mr.Arkin's birthday and I hope he will have a splendid birthday, if it weren't for Mr.Arkin I would not know how to make a website, who to construct a program, all the definitions I know about computer science would not exist in my mind. Therefore, I would like to say  hachi tov be mar Arkin! (means your the best Mr.Arkin). 

No comments:

Post a Comment