Monday 26 August 2013

Update Environment Variables - algorithms

1. The problem is that the environment variables need to be calculated to be updated.
2. The inputs are X, Y, R and T.
3. The outputs are X and Y.
4. The processing tasks are X incremented by R and Y incremented by T.
If X > 5000 then Y decremented by 1000.
If Y < 0, Y and X are set to 0.
5. Pseudocode

Update environment variables
Prompt user for X, Y, R and T

Get X, Y, R and T
X = X + R
Y = Y + T

If X > 5000
Y = Y - 1000

If Y < 0
Y = 0
X = 0

End


Tuesday 20 August 2013

Object modelling

TV remote
Attributes:  Buttons, Batteries, Brand, Colour
Behaviours:  Button press

USB
Attributes:  Brand, Colour, USB slot, Data capacity
Behaviours:  USB port insert

Phone
Attributes:  Numpad, Battery, Sim Card, SD card, Mic, Touch screen
Behaviours:  Makes calls, recieves calls, touch sensitive

Tuesday 13 August 2013

Switch flowchart


Switch

Switch Month
Case condition 1
Display "The number is 1"

Case condition 2
Display "The number is 2"

Case condition 3
Display "The number is 3"

Case condition 4
Display "The number is 4"

Case condition 5
Display "The number is 5"

Case condition 6
Display "The number is 6"

Case condition 7
Display "The number is 7"

Case condition 8
Display "The number is 8"

Case condition 9
Display "The number is 9"

Case condition 10
Display "The number is 10"

Case condition 11
Display "The number is 11"

Case condition 12
Display "The number is 12"

Case Else
Prompt user to re-enter value

End Select

And

The value that needs to be stored in Number to display the message "This number does not meet the condition" are 7 or less or 11 or higher.

Monday 12 August 2013

Or

The numbers 5, 6, 7 and 8 would need to be stored in Number to make the program display the message "This number does not meet the condition".

Validation and error trapping

1. 
Pseudocode
Calculate price of sending parcel
Prompt user for ItemWeight, CostPerKilo
Get ItemWeight, CostPerKilo

If ItemWeight is a number and CostPerKilo is a number
 
CostofSendingParcel = ItemWeight * CostPerKilo
If CostofSendingParcel < 100
Display CostofSendingParcel
Else
CostAfterDiscount = CostofSendingParcel * 0.9
Display CostAfterDiscount
End If

Else Display ErrorMessage
 
End
2.
 

Tuesday 6 August 2013

Apply Discount

 
Apply discount algorithm
 
Defining the problem:
The problem is that we need to find the cost of sending a parcel to someone and calculating the discount if the cost is more than $100.
 
Defining the inputs:
The inputs are; ItemWeight, CostPerKilo
 
Defining the outputs:
The outputs are; CostofSendingParcel, CostAfterDiscount
 
Define the processing:
1.  Get the item weight
2.  Get the cost per kilo
3.  Calculate the cost of sending a parcel
4.  If the cost of sending a parcel is less than $100, display the cost of sending a parcel
5.  Else, apply a 10% discount
6.  Display the cost after discount
 
Pseudocode
Calculate price of sending parcel
Prompt user for ItemWeight, CostPerKilo
 
Get ItemWeight, CostPerKilo
 
CostofSendingParcel = ItemWeight * CostPerKilo
 
If CostofSendingParcel < 100
Display CostofSendingParcel
Else
CostAfterDiscount = CostofSendingParcel * 0.9
Display CostAfterDiscount
End If
End

Monday 5 August 2013

Flowchart 1



Send a parcel algorithm

Task 1
1.  The problem is that we need to find the price of sending a parcel.
2.  The inputs are the weight of the parcel and the price per kiloram.
3.  The output is the final cost of sending the parcel.
4.
i) Get the items weight
ii) Get the standard charge per kilo
iii) Calculate the price of sending the item
iv) Display the price of sending the item
5.  Pseudocode
Calculate price of sending parcel

Prompt user for ItemWeight, CostPerKilo
Get ItemWeight, CostPerKilo
CostofSendingParcel = ItemWeight*CostPerKilo
Display CostofSendingParcel

Task 2
The steps ti creating an algorithm are:
Step 1: Define the problem
Step 2: Define the inputs
Step 3: Define the outputs
Step 4: Define processing
Step 5: Write the pseudocode