Monday, May 24, 2010

Learning & Assessment Activity 4.7


Learning & Assessment Activity 4.6

What happened when you removed the – 1 from the For loop end value?

This is what happened,I have taken a screen shot of the error message that displayed after I finished entering the names of my invitees into the input boxes,the first time I did this I got a list of the peoples name that I had input into the boxes in my form,now that I have taken the -1 away I don't get any list at all just this error.

Sunday, May 23, 2010

Learning & Assessment Activity 4.5


Learning & Assessment Activity 4.4

Learning & Assessment Activity 4.3

1. Revisit the project named LA_1.6

2. Answer the following questions:

• Is the code inside of the Ends button an example of a Do While or a Do Until loop?

It is Do While

• What is the condition being tested?

intCount <= 1

• How is the condition changed?

By changing either the < which means less then to > which means greater than or by changing the number
which in this case is =1 to any other number that may be required. For example a change such as the one below could be used.

Do While intCount >= 10

Monday, May 17, 2010

Learning & Assessment Activity 4.2

1. Create a new Visual Studio project and call it LA_Activity_4.2

2. Write the Visual Basic.NET code to execute the following algorithm in the Load behavior of the form:

For counter 3-10
Prompt user for a number
Display the number to the user
Next

3. Publish a screen shot of your code and any comments that you have to your assessment document.









When I enter a number in the input box that appears when I run the program, the message box then displays the following:


















4. Answer the following question: How many times does this loop execute? Publish your answer to your assessment document.

#The loop executes 8 times

Learning & Assessment Activity 4.1

The button that ends actually does end and the button that never ends continues until you stop running the code.They both have the loop code in them.The button that never ends contains in the code an infinite loop,meaning a loop that never ends.

Monday, May 10, 2010

Learning & Assessment Activity 3.15

1. Create a new Visual Studio project and name it LA_Activity_3.15

2. Code a select case statement that will ask a user for a colour and then matches that colour against pink, red, blue, yellow and aqua, giving a correct message if they have entered any of these colours, and an incorrect message if they entered any other colour.

3. Publish a screen shot of your code and any comments you have to your assessment document.

My code:











A correct message when i type in a color that is within the code:












An incorrect message when i type in a color that is not within the code:

Learning & Assessment Activity 3.14













As you can see from my code above i have modified it so that when you use either upper or lower case letters in your answer they will both work now.

Learning & Assessment Activity 3.13

1. Reopen the project named LA_3.12

2. Click the Click here! button and then answer the question (start the word with a lower case letter).

This is what i got when i entered Monday with a lower case letter:













3. Explain why you got the message you did after you entered your input.

The days of the week in the code begin with capital letters, i changed the day of the week Friday from having an upper case letter to a lower case letter and when i executed the code,it worked. If the code uses upper case letters then you must type upper case letters into the text box when answering the question because the program sees the string "Friday" as different from the string "friday"

4. What message would be displayed if the user entered the day with a starting upper case letter?
The corresponding message to the answer would be displayed,the correct answer and not "I don't recognise the day you have entered. Try again" message.

Learning & Assessment Activity 3.12


Above:I typed in Tuesday for my favorite day of the week, and this is the message that appeared in the msg box

Learning & Assessment Activity 3.11

1. Read the following Visual Basic.NET code:

If  intMyNumber > 10 or intMyNumber < 8 Then

Msg ("My number meets the condition")

Else

Msg ("My number does not meet the condition")

End If
 
2. Answer the following question:

What number would need to be stored in intMyNumber to make this program display the message “My number does not meet the condition”? Why?

3. Publish your answer to your assessment document.

This is incorrect and so i have not answered this question as Rachael told me not to.

Learning & Assessment Activity 3.10

1. Create a new Visual Studio project and name it LA_Activity_3.10

2. Use the If...Then...Else statement to incorporate validation into the algorithm you modified in activity 3.6

3. Publish a screen shot of your code and any commments that you have to your assessment document.













And here is my code that shows my If  IsNumeric statement:

Learning & Assessment Activity 3.9

My Code:













As you can see when i put in text instead of numbers this message appears:

Learning & Assessment Activity 3.8

1. Locate and open the project from activity 3.3

2. Add the If...Else...Then statement (for the validation) to the code as per the following (code to be added is highlighted with red shading):

3. Run the project and enter the numbers into the textbox. The program should execute as it did in activity 3.3

4. Run the project again and test the If statement by the entering text instead of numbers into one or more of the textboxes.

This is what happened:












5. Change the message the user recieves in the message box to “Please enter numbers only! I am not magic!”

6. Publish a screen shot of the new message box message to your assessment document.

My screen shot:













I thought i would also publish a screen shot of my code:

Learning & Assessment Activity 3.7

1. Create a new project in Visual Studio and name it LA_Activity_3.7

2. Enter the following code in the Load behavior of Form 1: My Code:



3. Run the project and enter the number 11 when the InputBox prompts you to enter a number.




The final message showed the number 11 because the value of intUserNumber was greater than ( > ) the value of intProgramNumber. This caused the If statement to execute, causing the value of intProgramNumber to be changed to the value of intUserNumber. The program then executed the final line of code which displayed the value of intProgramNumber.

4. Re-run the project and this time enter the number 9 when the InputBox prompts you to enter a number.











 This time the final message showed the number 10 because the value of intUserNumber was not greater than the value of intProgramNumber. The If statement was not executed, so the value of intProgramNumber was not changed. The program simply skiped the If statement and executee the final line of code, displaying the value of intProgramNumber.

Sunday, May 9, 2010

Learning & Assessment Activity 3.6

1. Create a new Visual Studio project and name it LA_Activity_3.6

2. Write the code for the pseudocode algorithm you created in activity 3.2

3. Run the project to ensure you get the correct response by entering correct and incorrect data.

4. Publish a screen shot of your code, the pseudocode algorithm and any comments that you have to your assessment document.

My Code:














If...











Else...

 

Learning & Assessment Activity 3.5

1. Create a new Visual Studio project and name it LA_Activity_3.5

2. Write the code for the pseudocode algorithm you created in activity 3.1

3. Run the project to ensure you get the correct response by entering correct and incorrect data.

4. Publish a screen shot of your code, the pseudocode algorithm and any comments you have to your assessment document.

The code for the pseudocode algorithm:















If...













Else...













Notice the final message will vary according to whether the condition in the If...Then...Else statement is met.
When the condition decCostOfParcel > $100 is tested it evaluates to true or false and executes the correct code block accordingly.

Learning & Assessment Activity 3.4

What message should be displayed in the message box if you entered the following
amounts into the TextBoxes?

• 50 (weekly income)
• 30 (living expenses)
• 1000 (price of the new computer)

1. Test the LA_Activity_2.2 program to see if you are correct.

2. Publish your answer to your assessment document.

Learning & Assessment Activity 3.3

Locate and open the file LA_Activity_2.2 created in activity 2.2.

2. Delete or comment-out the final line of code that displays the MsgBox.

3. Add the following code to the end of the remaining code to incorporate which message should be displayed:

4. Run the project.

5. Enter each value in turn.

My Code:












6. Publish a screen shot of the message box that is executed in the IF part of the statement to your assessment document.











7. Publish a screen shot of the message box that is executed in the ELSE part of the statement to your assessment document.


Tuesday, May 4, 2010

Learning & Assessment Activity 3.2

1. Create a flow chart algorithm for the following problem (modified from activity 1.2)

You want to estimate the number of hours it will take you to complete all of the levels in a new video game based on your past performance with other games.If it will take less than 5 hours,display a message that says you are a great player,otherwise display the total number of hours.

2. Publish a screen shot of your flow chart to your assessment document.

Learning & Assessment Activity 3.1

1. Create a pseudocode algorithm for the following problem (modified from activity 1.1)

You need to know the cost of sending a parcel to someone.the price of sending the item will depend upon its weight. The postal service has a standard charge per kilo of item weight.If the postage charge is greater then $100.00,a %10 discount is applied to the amount.

2. Publish the algorithm to your assessment document.

Calculate the cost of the parcel
Prompt the user for the parcel weight
Get the parcel weight
Validate parcel weight
Prompt the user for the standard charge
Get the standard charge
Validate standard charge
Parcel weight x Standard charge
If Cost Of  Parcel >$100.00 then
Display Cost Of Parcel + "You recieve a %10 discount"
Else
Display the cost of the parcel
End If
Close Display

Monday, May 3, 2010

Learning & Assessment Activity 2.4

1. Create a new Visual Studio project and call it LA_Activity_2.4

2. Arrange controls on Form 1 as per the requirements of your algorithm from activity 1.2

3. Convert the algorithm you created in activity 1.2 to sequential code using Visual Basic.NET. (Ignore the input validation part for now)

4. Publish a screen shot of your code plus a description to your Chapter 2 assessment document











Let me explain my code(above)to you.

The first three lines of code (Dim) declare my variables that will be used in my algorithm.

In this case the variables will store the data type:decimal.

The next two lines of code (example:txtNoOfLevels.Text) will assign the inputs from the Text Boxes to each of the variables in turn.

The input gathered by a Text Box is treated as a String data type,this is done by default.
For this reason conversion functions have been used in the two lines to convert the default string into the data type of decimal.

The next line determines the number of hours by performing a multiplication operation(NoOfLevels x PastPerformance) using the(*)operator.

The result is then displayed to the user in a message box and the algorithm is complete.
When the program is executed this is the result:

Learning & Assessment Activity 2.3

1. Create a new Visual Studio project and call it LA_Activity_2.3

2. Arrange controls on Form 1 as per the requirements of your algorithm from activity 1.1

3. Convert the algorithm you created in activity 1.1 to sequential code using Visual Basic.NET. (Ignore the input validation part for now)

4. Publish a screen shot of your code plus a description to your Chapter 2 assessment document










Let me explain my code(above)to you.

The first three lines of code (Dim) declare my variables that will be used in my algorithm.

In this case the variables will store the data type:decimal.

The next two lines of code (example :decParcelWeight = TextParcelWeight.Text) will assign the inputs from the Text Boxes to each of the variables in turn.

The input gathered by a Text Box is treated as a String data type,this is done by default.
For this reason conversion functions have been used in the two lines to convert the default string into the data type of decimal.

The next line determines the cost of the parcel by performing a multiplication operation(Parcel Weight x Standard Cost) using the(*)operator.

The result is then displayed to the user in a message box and the algorithm is complete.
When the program is executed this is the result:

Sunday, May 2, 2010

Learning & Assessment Activity 2.2

1. Locate and open the project named LA_Activity_2.2

2. Enter the following code in the Load behavior of Form 1:





3. Enter the following code in the Click behavior of the button:















4. Run the project.

5. Enter each value in turn.

6. Publish the following to your Chapter 2 assessment document:

The value you provided for weekly wages

500

The value you provided for weekly living expenses

200

The value you provided for the price of the new computer

100

A screen shot of the final message box where the result is displayed

Learning & Assessment Activity 2.1

1. Compare the following Simple Problem algorithm below to the correct one above:

2. Answer the following questions:
• What is the difference between the two algorithms?
• What would happen if the algorithm in this activity was used to create a
programming solution to the Simple Problem?

3. Publish your answers to your Chapter 2 assessment document.

The difference is that the first algorithm was in the correct sequence, the right order so for this reason the task would be able to be completed and the problem solved whereas in the second algorithm all of the processes were out of sequence/order so for this reason the problem would not be able to be prompted, validated, calculated and solved. For the task to be completed the algorithm must be correct.

If the algorithm in this activity was used to create a programming solution to the Simple Problem it would simply not solve any problems as the information is in the incorrect order.It would crash.