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). 

Wednesday, November 24, 2010

Wednesday- Arrays Are ...... How Should I Say This?

An array of pins

  Today we learned about a new keyword known as array, an array is a data structure that can store more than one variable, where as a variable (var) can only store one variable at a time. An array will allow me to hold many variable in one location, therefore it will make my life much more easier. These arrays have made my assignment #12 look much more sophisticated when it is run. This also makes most my programs much more efficient and easy to use, as we learn more and more about Turing I start to realize how hard this language must have been to make.


  The amount of effort that was put into making this language is utterly mind boggling. The only thing that is bothering my at the moment is, how can I output all the variables stored in the array with a put statement. If I find out how to do this I will finish the modified version of assignment #12.

Tuesday, November 23, 2010

Tuesday- Becoming Much Better at Turing

  Today I asked Mr.Arkin if he could check my program for any errors. Surprisingly I had a sparse amount of errors, which would let the program run efficiently, however did not go by how a program should be indented. I also learned not to combine the initialization section with the declaration section. My programs are looking much better that what they use to be. Nonetheless, something I forgot to do was check my printer comparison mark! This made me extremely frustrated and due to preoccupations I could not go and see it. This is keeping me anxious and worried at the same time. Tomorrow we will also be receiving our term 1 report cards, my average is descent, however I want my average to be in the 90's and not the 80's, therefore I will keep working hard to accomplish my goal. 

Monday, November 22, 2010

Monday- Coming Back From a Long Weekend!

  I went to sleep last night unaware of school tomorrow, my alarm clock rung and suddenly I came back to Earth. It was as if though I were in a serene paradise, then suddenly someone shoot me down. I woke up wary and wanting nothing else but sleep. Another factor that really made me drowsy today was the swimming practice I had in the morning. I woke up at 6 am and was at school by 7, as I said in my previous blogs, the harder and more efficient someone works on something the better the outcome will be. The power of the human being is only limited by there own thoughts. This reminds me of a story that my father told me about the Olympic games. He said that a Spanish swimmer lost to an American swimmer, some years ago, due to what his mind was occupied with. The swimmer who lost thought the victor was much better than him, however it was not so. This is mainly because the victor's time was lower than the other swimmers when there was no competition involved. Therefore, this story taught me to always think that I am better and that those who think they will lose will end up losing.

Thursday, November 18, 2010

Thursday- HTML Again?!

  Today we started using notepad and creating websites, the last time I created a website was a month ago. I most refresh my mind and try to remember all the materials I have forgotten in this long duration of time. As my programming skills improved drastically, my website designing skills have significantly dropped. Another problem that is occurring for me is, someone is deleting my index page, this both makes me infuriated and perplexed. As I think about alternative to deal with this matter I find none, on Monday, I will consult this dilemma with Mr.Arkin, because this has been the fourth time someone has deleted my index page. All problems aside this year is turning out to be quite congenial. 


  Today as I am typing this post, 8th graders from all different locations in Toronto and possibly other cities are gathering in either the cafeteria or library, for information night. I remember the day I was required to attend to information night, as I glanced to the crowd of students wanting to get into IB I wanted to turn back, however determination and dedication are key to fulfilling a goal. I remember at one point in Mr.Usprech's lecture I had an urge to get up and leave the room, nonetheless I made it, no one would have guessed it. That day I felt like my dreams were coming true and now that I think about a crowd of 8th graders and their parents swarming around Mr.Usprech or a t.v screen, I laugh saying all that nervousness and anxiousness was worth it, it was worth getting a first degree education.     

Wednesday, November 17, 2010

Wednesday - Rest of Repetition Assignments

    As I stated in my last post, I did not want my posts to become so clustered with information, therefore I decided to post the rest of the repetition assignments (# 11, 12, 13) on this post. If there are any mistakes please comment on this post and I will do my best to fix, as soon as possible. Here they are:

#11

%declaration section
var sum_of_numbers : int := 0
var number : int
var total_of_numbers : int := 0
var mean : real
var answer : string

%input and processing section
loop
    colourback ( black )
    cls
    colour (43)
    put "Number? : " ..
    get number
    if number not= 0 then
    sum_of_numbers := number + sum_of_numbers
    total_of_numbers := total_of_numbers + 1
    colour (5)
    put skip, "You have ", total_of_numbers, " number stated."
    colour (red)
    put skip, "The sum of your numbers is, ", sum_of_numbers, "."
    colour (9)
    put skip, "More numbers (yes/no)? " ..
    get answer
    else
    put skip, "Enter any number other than 0 "
    end if
    exit when answer = "no" or answer = "NO" or answer = "No"
end loop

% extro
colourback (blue)
cls
mean := sum_of_numbers / total_of_numbers
colour (8)
put "The mean of your marks is: ", mean : 0 : 2

# 12

% documentation section
% Produce a cash-register receipt: Gather price and tax-status data,
% item by item, display those data, then display the total PST, total GST,  

and overall total. (Hints: For each item, gather the price and its   
% taxable status with a single get statement, and use an appropriate
% number of accumulators. )

%
% declaration section
const GST := 0.05
const PST := 0.08

var answer : string
var item_price : real
var number_of_items : int := 0
var tax_status : string
var total : real := 0
var total_without_tax : real := 0
var tax_PST : real := 0
var tax_GST : real := 0

% input and processing section
loop
colourback(black)
cls
colour ( 43 )
put "Item price: $" ..
get item_price

if item_price > 0 then
number_of_items := number_of_items + 1
tax_GST := GST * item_price
tax_PST := PST * item_price
total_without_tax := total + item_price
total := total + item_price + tax_GST + tax_PST

colour(white)
put repeat ("=" ,20)
put repeat ("=" ,20)

colour(red)
put skip, "Price of item(s) : $", total_without_tax : 0 : 2
put skip, "GST : $", tax_GST : 0 : 2
put skip, "PST : $", tax_PST : 0 : 2
put skip, "Total : $", total : 0 : 2
put skip, "Number of items : $", number_of_items
colour(white)
put repeat ("-" ,20)
else
put "Please enter valid price!"
end if
colour(purple)
put skip, "Continue? (y/n) " ..
get answer
exit when answer = "n" or answer = "N"
end loop
% extro
colourback (red)
cls
colour(blue)
put "Thank you! " 

# 13

% declaration section
const child := 5
const adult := 10
const senior := 7.50
var ticket_type : string
var number_of_tickets : int := 0
var total_price_of_tickets : real := 0
var answer : string
% input and processing section
loop
    colourback (black)
    cls
    colour (43)
    put "Ticket type (adult/senior/children) : " ..
    get ticket_type
    number_of_tickets := number_of_tickets + 1
    if ticket_type = "adult" or ticket_type = "Adult" or ticket_type = "ADULT" then
        total_price_of_tickets := total_price_of_tickets + adult
    elsif ticket_type = "senior" or ticket_type = "Senior" or ticket_type = "SENIOR" then
        total_price_of_tickets := total_price_of_tickets + senior
    elsif ticket_type = "children" or ticket_type = "Children" or ticket_type = "CHILDREN" then
        total_price_of_tickets := total_price_of_tickets + child
    else
        put "Enter valid type of ticket ! "
    end if
    colour (red)
   
    put "Continue? (y/n) " ..
    get answer
    exit when answer = "n" or answer = "N"
end loop
% extro
colour (purple)
put "The total amount of tickets you purchased is : ", number_of_tickets, ", and must pay : $", total_price_of_tickets : 0 : 2, " for the tickets. "
 
  I hope these assignments can help everyone carry on with the repetition assignments. Once more if anyone has any questions or concerns please comment on this post, I will truly appreciate it.

Tuesday, November 16, 2010

Tuesday- Handed in my Best Work for Repetition

  My best work that I have made so far, when it comes to the repetition assignments was handed in today, I hope I did well. I added color to this assignment, which I believe is extremely important as I stated in my previous post. However, the section that I believe will give me a higher mark is the processing section, because, to make my job easier I used a for statement to make my program much shorter. I am slowly starting to use much more sophisticated procedures, functions and keywords to make my program more efficient and compact to make it both easier for me (being the programmer) and the user. I am also posting the codes for questions 7, 9 and 10 on this post to help my peers work ahead on the repetition assignments and the main reason why I did not put 8 is because, I do not know if I did it properly, therefore I do not want to mislead anybody. 















#7 
for number : 1 .. 34


    colourback (green)


    colour (yellow)


    delay (500)


    put repeat ("*", number)


end for


%extro


colourback (blue)


colour (red)


put "Done!"

#9



var number1 : real
var answer : string
var negative_value : real


loop
    put "What is your number? " ..
    get number1
    if number1 not= 0 then 
    negative_value := number1 - number1 - number1
    put number1, " negative = ", negative_value
    put "Continue? (yes/no) " ..
    get answer
    else
    put "Enter valid number!"
    end if 
    exit when answer = "no"
end loop

# 10

% documentation section
% Gather a set of non-zero integers, and
% display both the number of positive
% and the number of negative integers processed.

%declaration section
var number : real
var answer : string
var negative_number_count : int := 0
var positive_number_count : int := 0

% processing section and input section

loop
    colourback ( black )
    cls
    colour ( yellow )
    put "Number? : " ..
    get number
    if number > 0 then
        positive_number_count := positive_number_count + 1
    elsif number < 0 then
        negative_number_count := negative_number_count + 1
    else
        colour ( white )
        put "Enter number that is not 0!"
    end if
        colour ( purple )
    put skip, "Positive number count = ", positive_number_count
        colour ( red )
    put skip, "Negative number count = ", negative_number_count
        colour ( 43 )
    put skip, "Continue? (y/n) " .. 
    get answer
    exit when answer = "n" or answer = "N"
end loop

% extro
put skip, "Done!"


  I hope this will help my peers proceed with repetition, I will post the rest on my next post, because I did not want to make this post extremely long. 

Monday - Adding Color to my Assignments

  Today Mr.Arkin showed us an extremely well constructed program that involves changing the color of the background and letters. Now that I look back at previous programs that I had made, I think about how much better they would be if I were to add in color. The color to a program is like adding pictures to a project, it makes the work much more appealing towards the eye, therefore catching people's attention. This is a good thing in programming because, if the program was dull, the user would not recommend this to other people, therefore if a person were trying to make profit out of the program, they wouldn't be. Color in my opinion adds a certain perfection like attribute to the program, this is why I have decided to add color to all my programs! See the difference between this text and the colorful text?

Monday, November 15, 2010

Friday- NO HOMEWORK

 


Finishing assignments earlier than required to does indeed pay off, today if I did not go on to doing the repetition assignments I would have homework, however due to working ahead I do not. I am working on the substring assignments, I believe if I set my mind to doing the assignments I will finish them all by Monday. I hope Mr.Arkin does not have any more assignments to bestow on me. I am also going to the YMCA today to take a load off my playing basketball and going swimming. The song is stuck in my head now : 





Young man, there's no need to feel down
I said, young man, pick yourself off the ground
I said, young man, 'cause your in a new town
There's no need to be unhappy

Young man, there's a place you can go
I said, young man, when you're short on your dough
You can stay there, and I'm sure you will find
Many ways to have a good time.

It's fun to stay at the Y.M.C.A.
It's fun to stay at the Y.M.C.A.
They have everything For young men to enjoy.
You can hang out with all the boys.

It's fun to stay at the Y.M.C.A.
It's fun to stay at the Y.M.C.A.
You can get yourself clean
You can have a good meal
You can do whatever you feel.

Young man, Are you listening to me
I said, young man, what do you want to be
I said, young man, you can make real your dreams,
but you've got to know this one thing.

No man, does it all by himself
I said, young man, put your pride on the shelf
And just go there, to the Y.M.C.A.
I'm sure they can help you today

It's fun to stay at the Y.M.C.A.
It's fun to stay at the Y.M.C.A.
They have everything for young men to enjoy.
You can hang out with all the boys.

It's fun to stay at the Y.M.C.A.
It's fun to stay at the Y.M.C.A.
You can get yourself clean
You can have a good meal
You can do whatever you feel.

Young Man, I was once in your shoes,
I said, I was down and out with the blues
I felt, no man cared if I were alive
I felt the whole world was so jive

That's when someone came up to me
and said young man take a walk up the street
There's a place there called the Y.M.C.A.
They can start you back on your way.

It's fun to stay at the Y.M.C.A.
It's fun to stay at the Y.M.C.A.
They have everything For young men to enjoy.
You can hang out with all the boys.

Y.M.C.A.
It's fun to stay at the Y.M.C.A.
It's fun to stay at the Y.M.C.A.
Young man, Young man, there's no need to feel down
Young man, Young man, pick yourself off the ground

Y.M.C.A.
just go to the Y.M.C.A.
Young Man, Young Man, I was once in your shoes,
Young Man, Young Man, I was out with the blues

Y.M.C.A.
Y.M.C.A.
Y.M.C.A.
Y.M.C.A.

Saturday, November 13, 2010

Thursday- Got Test Back


         I expected much better from myself, even though I studied for long durations of time I could not achieve my goal, my standard. However, as I was consulting the marks with my other peers I noticed that my mark was excellent compared to theirs. 


        Today I also asked Mr.Arkin about substrings, hears what I learned : for the first letter of a word to be displayed the variable name must be given in a put statement followed by (1), for the second letter it is the same case scenario, however (2) replace (1). For the last letter of a word to be displayed, the variable name is stated in a put statement and is followed by (*). For the second last letter in a word  the variable name is stated in a put statement and is followed by (* - 1). Here is the code for the first two substring assignments :

#1

const DELAY := 1000


var letters : int
var name : string


put "Letters? (no more than 6) : " ..
get letters


put "Word? : " ..
get name : *


case letters of


    label 6 :
        put name (1)
        delay(DELAY)
        put name (2)
        delay(DELAY)
        put name (3)
        delay(DELAY)
        put name (4)
        delay(DELAY)
        put name (* -1)
        delay(DELAY)
        put name (*)
        delay(DELAY)


    label 5 :
        put name (1)
        delay(DELAY)
        put name (2)
        delay(DELAY)
        put name (3)
        delay(DELAY)
        put name (* -1)
        delay(DELAY)
        put name (*)
        delay(DELAY)


    label 4 :
        put name (1)
        delay(DELAY)
        put name (2)
        delay(DELAY)
        put name (* -1)
        delay(DELAY)
        put name (*)
        delay(DELAY)


    label 3 :
        put name (1)
        delay(DELAY)
        put name (* -1)
        delay(DELAY)
        put name (*)
        delay(DELAY)


    label 2 :
        put name (1)
        delay(DELAY)
        put name (*)
        delay(DELAY)


    label 1 :
        put name (1)
        delay(DELAY)


    label :
        put "Please enter valid letter count!"


end case


put "Done!"



#2
const DELAY := 1000


var letters : int
var name : string


put "Letters for word? (no more than 6) : " ..
get letters


put "Word? : " ..
get name : *


case letters of


    label 6 :
        put name (*)
        delay(DELAY)
        put name (*-1)
        delay(DELAY)
        put name (4)
        delay(DELAY)
        put name (3)
        delay(DELAY)
        put name (2)
        delay(DELAY)
        put name (1)
        delay(DELAY)


    label 5 :
        put name (*)
        delay(DELAY)
        put name (*-1)
        delay(DELAY)
        put name (3)
        delay(DELAY)
        put name (2)
        delay(DELAY)
        put name (1)
        delay(DELAY)


    label 4 :
        put name (*)
        delay(DELAY)
        put name (*-1)
        delay(DELAY)
        put name (2)
        delay(DELAY)
        put name (1)
        delay(DELAY)


    label 3 :
        put name(*)
        delay(DELAY)
        put name(*-1)
        delay(DELAY)
        put name(1)
        delay(DELAY)


    label 2 :
        put name(*)
        delay(DELAY)
        put name(1)
        delay(DELAY)


    label 1 :
        put name (1)
        delay(DELAY)


    label :
        put "Please enter valid letter count!"


end case


put "Thank you!"


  I will try and do as many assignments I am capable of doing, if I cannot do some of them they I shall ask Mr.Arkin for advice. 

Thursday, November 11, 2010

Wednesday- Test Day!

  The test was challenging, however I believe I did exceptionally well on it, I completed all questions without a problem. However, "never count your chickens before they hatch." That is the saying that I remind myself with, I believe those who "count their chickens" will end up with devastating results. One should always look at other alternatives and perspectives, not only what they think will be the outcome. I am so anxious to see what my mark is, I want to also see my mistakes, therefore I can learn from them and patten my thinking for latter on test experiences.  

Tuesday, November 9, 2010

Tuesday- Studying for the Test!

  I believe all I need to do now for the computer science test tomorrow is to review all the notes I took on programming. The only thing that is really bothering me right now is what if I make an extremely small mistake for constructing programs, like misplacing a comma or forgetting a quotation mark. I want to get a high mark on this so that it may raise my ICS mark. Thursday is Remembrancer day and when I look back I ask myself why do people fight in the first place.