Tuesday, 14 October 2014

JavaScript Operators

JavaScript uses arithmetic operators to compute values (just like algebra):
(5 + 6) * 10
Try it Yourself »
JavaScript uses an assignment operator to assign values to variables (just like algebra):
x = 5;
y = 6;
z = (x + y) * 10;
Try it Yourself »





JavaScript Statements

A computer program is a sequences of "executable commands" called statements.
JavaScript statements are separated by semicolon:
x = 5 + 6;
y = x * 10;
Multiple statements on one line is allowed:
x = 5 + 6; y = x * 10;












 JavaScript Keywords

A JavaScript statement often starts with a keyword.
The var keyword tells the browser to create a new variable:
var x = 5 + 6;
var y = x * 10

JavaScript Data Types

JavaScript variables can hold many data types: numbers, text strings, arrays, objects and more:
var length = 16;                               // Number assigned by a number literal var points = x * 10;                           // Number assigned by an expression literal var lastName = "Johnson";                      // String assigned by a string literal var cars = ["Saab", "Volvo", "BMW"];           // Array  assigned by an array literalvar x = {firstName:"John", lastName:"Doe"};    // Object assigned by an object literal

  JavaScript Functions

JavaScript statements written inside a function, can be invoked and reused many times.
Invoke a function = call a function (ask for the code in the function to be executed).
function myFunction(a, b) {
    return a * b;                   // return the product of a and b


 



JavaScript Statement

In HTML, JavaScript statements are "command lines" executed by the web browser.

In HTML, JavaScript statements are "commands" to the browser.
The purpose, of the statements, is to tell the browser what to do.
This statement tells the browser to write "Hello Dolly" inside an HTML element identified with id="demo":

Example

document.getElementById("demo").innerHTML = "Hello Dolly.";

Try it Yourself »

 JavaScript Code

JavaScript code (or just JavaScript) is a sequence of JavaScript statements.
Each statement is executed by the browser in the sequence they are written.
This example will manipulate two different HTML elements:

Example

document.getElementById("demo").innerHTML = "Hello Dolly.";
document.getElementById("myDiv").innerHTML = "How are you?";

Try it Yourself »


Semicolon ;

Semicolon separates JavaScript statements.
Normally you add a semicolon at the end of each executable statement:
a = 5;
b = 6;
c = a + b;

Try it Yourself »
N/B 
You might see examples without semicolons.
Ending statements with semicolon is optional in JavaScript.

 JavaScript Code Blocks

JavaScript statements can be grouped together in blocks.
Blocks start with a left curly bracket, and end with a right curly bracket.
The purpose of a block is to make the sequence of statements execute together.
A good example of statements grouped together in blocks, are in JavaScript functions.
This example will run a function that will manipulate two HTML elements:

Example

function myFunction() {
    document.getElementById("demo").innerHTML = "Hello Dolly.";
    document.getElementById("myDIV").innerHTML = "How are you?";
}

Try it Yourself »
 

JavaScript Statement Identifiers

JavaScript statements often start with a statement identifier to identify the JavaScript action to be performed.
Statement identifiers are reserved words and cannot be used as variable names (or any other things).
Here is a list of some of the JavaScript statements (reserved words) you will learn about in this tutorial:
Statement Description
break Terminates a switch or a loop
catch Marks the block of statements to be executed when an error occurs in a try block
continue Jumps out of a loop and starts at the top
debugger Stops the execution of JavaScript, and calls (if available) the debugging function
do ... while Executes a block of statements, and repeats the block, while a condition is true
for Marks a block of statements to be executed, as long as a condition is true
for ... in Marks a block of statements to be executed, for each element of an object (or array)
function Declares a function
if ... else Marks a block of statements to be executed, depending on a condition
return Exits a function
switch Marks a block of statements to be executed, depending on different cases
throw Throws (generates) an error
try Implements error handling to a block of statements
var Declares a variable
while Marks a block of statements to be executed, while a condition is true  

JavaScript Syntax

JavaScript is a scripting language. A scripting language is a lightweight programming language.
The sentences in a programming language are called statements.
The principles, how sentences are constructed in a language, are called language syntax.

JavaScript Literals

In a programming language, a literal is a constant value, like 3.14. Number literals can be written with or without decimals, and with or without scientific notation (e):
3.14
1001
123e5
 String literals can be written with double or single quotes:
"John Doe"
'John Doe'
Expression literals evaluate (compute) to values:
5 + 6
5 * 10
Try it Yourself »
Array literals defines an array:
[40, 100, 1, 5, 25, 10]
Object literals defines an object:
{firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"}
Function literals defines a function:
function myFunction(a, b) { return a * b;} 

JavaScript Variables

In a programming language (and in algebra), variables are used to store data values.
JavaScript uses the var keyword to define variables.
An equal sign is used to assign values to variables (just like algebra).
In this example, length is defined as a variable. Then, it is assigned (given) the value 6:
var length;
length = 6;
Try it Yourself »


A literal is a fixed value. A variable is a name that can have variable values.

JavaScript Output

JavaScript Output

JavaScript does not have any print or output functions.
In HTML, JavaScript can only be used to manipulate HTML elements.

Manipulating HTML Elements

To access an HTML element from JavaScript, you can use the document.getElementById(id) method.
Use the id attribute to identify the HTML element, and innerHTML to refer to the element content:
______________________________________________________________________________

Example

<!DOCTYPE html>
<html>
<body>

<h1>My First Web Page</h1>

<p id="demo">My First Paragraph</p>

<script>
document.getElementById("demo").innerHTML = "Paragraph changed.";
</script>

</body>
</html>
_______________________________________________________________________________
The JavaScript statement above (inside the

JAVA SCRIPT

Javascript Tutorials

JavaScript is one of 3 languages all web developers must learn:
 1. HTML to define the content of web pages 
2. CSS to specify the layout of web pages 
3. JavaScript to program the behavior of web pages
The HTML DOM (the Document Object Model) is the official W3C standard for accessing HTML elements.
JavaScript can manipulate the DOM (change HTML contents).
The following example changes the content (innerHTML) of an HTML element identified with id="demo": 

Example

document.getElementById("demo").innerHTML = "Hello JavaScript";

 The method document.getElementById() is one of many methods in the HTML DOM.

You can use JavaScript to:

  • Change HTML elements
  • Delete HTML elements
  • Create new HTML elements
  • Copy and clone HTML elements
  • And much more ... 




  • My First JavaScript



    JavaScript can change the content of an HTML element:




    This is a demonstration.



Thursday, 9 October 2014

batch commands

Learn some basic batch commands. Batch files run a series of DOS commands, so the commands that you can use are similar to DOS commands. Some of the more important ones include:
  • ECHO - Displays text on the screen
  • @ECHO OFF - Hides the text that is normally output
  • START - Run a file with it's default application
  • REM - Inserts a comment line in the program
  • MKDIR/RMDIR - Create and remove directories
  • DEL - Deletes a file or files
  • COPY - Copy a file or files
  • XCOPY - Allows you to copy files with extra options
  • FOR/IN/DO - This command lets you specify files.
  • TITLE - Edit's the title of the window. [1]  
  • Write the code to make a basic backup program. Batch files are great for running multiple commands, especially if you configure it to be able to run multiple times. With the XCOPY command, you can make a batch file that copies files from select folders to a backup folder, only overwriting files that have been updated since the last copy:
    @ECHO OFF 
    XCOPY c:\original c:\backupfolder /m /e /y
    
  • This copies over files from the folder "original" to the folder "backupfolder". You can replace these with the paths to the folders you want. /m specifies that only updated files will be copied, /e specifies that all subdirectories in the listed directory will be copied, and /y keeps the confirmation message appearing every time a file is overwritten.
  •  Write a more advanced backup program. While simply copying the files from one folder to another is nice, what if you want to do a little sorting at the same time? That's where the FOR/IN/DO command comes in. You can use that command to tell a file where to go depending on the extension:
    @ECHO OFF 
    cd c:\source
    REM This is the location of the files that you want to sort
    FOR %%f IN (*.doc *.txt) DO XCOPY c:\source\"%%f" c:\text /m /y
    REM This moves any files with a .doc or 
    REM .txt extension from c:\source to c:\text
    REM %%f is a variable
    FOR %%f IN (*.jpg *.png *.bmp) DO XCOPY C:\source\"%%f" c:\images /m /y
    REM This moves any files with a .jpg, .png, 
    REM or .bmp extension from c:\source to c:\images
    

Friday, 3 October 2014

USB ports

Disable USB ports on Windows PC via Registry

With this trick, you can disable access to your USB(Universal Serial Bus) ports on your Windows based PC to prevent people from taking out data without permission or spreading viruses through the use of USB (pen and flash) drives.

To use this trick to disable USB ports, follow the steps given below:-

  1. Click on Start.
  2. Click on Run. If you cannot find RUN, type it in the search box.
  3. Type "regedit" without quotes. This will launch the Registry Editor.
  4. Navigate to  HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\usbstor.
  5. In the work area, double click on Start.
  6. In the Value Data box, enter 4.
  7. Click on OK.
  8. Close Registry Editor and refresh your desktop.
  9. To re-enable access to your USB ports, enter 3 in the Value Data box in Step 6.

Disable access to USB ports on your PC using Registry Editor

Data recovery

Recover Deleted files in Windows with Free Tools

Have you ever deleted a file that you did not wish to and wanted to recover it but did not find it in the recycle bin? You probably deleted it permanently with Shift+Delete or emptied the Recycle Bin. Now what? Don't worry, you may still have a chance to get it back. This article lists some free software that can recover deleted files from your hard drive or any other storage device instantly.

But how do the software mentioned below undelete deleted files?

When files are deleted, Windows does not delete them from your hard disk. It marks the storage space as empty for new data to be written and deletes the index entry that tells the location of those files. Unless, new files are written on that space, the deleted files are still recoverable. That's what allows these software to recover deleted files.

There are many free software that allow users to do this. Some of them are given below:-

1) Pandora Recovery
recover deleted files in Windows
Pandora Recovery is a free software that offers a wizard based interface for recovering files. It allows you to browse a drive's individual folders to look for deleted files. It also allows you search for a deleted file based on its name, file size, creation date and last access time. Its deep scan allows you to recover files that other software might have missed. Although deep scan does not return a file's original name and location, it still is effective to recover data from drives with corrupted file tables and drives that were recently formatted. It can even recover data from CDs and DVDs.

2) TOKIWA DataRecovery
undelete files in Windows
At just over 200KB, TOKIWA DataRecovery is the smallest file recovery program in the market. It supports undeletion from FAT 12, FAT16, FAT32 and NTFS file systems. It also supports recovering NTFS compressed and EFS encrypted files. This software supports Windows and is portable as well. It also has a file shredder that allows you to wipe out files in a manner that they cannot be recovered again.

3) Recuva
undelete files
Another great freeware, Recuva offers a wizard based interface to unerase files. Recuva offers scanning deleted files based on their type (music, pictures, videos etc.). It also allows deep scanning in case a file you deleted is unrecoverable via normal search. Like TOKIWA DataRecovery, Recuva also offers securely deleting files. Recuva also has a portable version that you can keep in your flash drive.

Keyboard Shortcuts

Useful Keyboard Shortcuts for Windows Computers

While most of us are already aware of obvious keyboard shortcuts like “Alt+F4” and “Ctrl+C”, there are some obscure shortcuts which most of us tend to overlook. These keyboard shortcuts are not only useful for the average PC user but for advanced users as well. This article contains many such amazing keyboard shortcuts which if used properly could save a lot of time and effort. So let's get started.
Windows key+D: This shortcut is the keyboard equivalent of “Show the Desktop”. It is useful for quickly minimizing every open window when someone walks in and you are doing some private work.
Keyboard Shortcuts Windows

Ctrl+Shift+Esc: This shortcut directly starts the task manager. While Alt+Ctrl+Del was used to bring out the Task Manager in Windows XP and earlier versions, in Windows 8.1, Windows 8 and Windows 7, it just brings up the lock this computer screen.
Ctrl+Click: This shortcut is useful for opening a link in a background tab. This is useful when you have to load a page without leaving the current one.
Alt+Print Screen: takes the screenshot of the current active window as opposed to just Print Screen which takes the screenshot of the entire screen.
Shift+Click for Yes to All and No to All: If you have a lot of dialog boxes asking yes and no question, just shift+click Yes or No on one to yes all or no all.
Ctrl+C on an error dialog box to copy its contents: Suppose your computer is giving an error message and you want to copy its contents to send to the support guy, what do you do? Just press Ctrl+C while the dialog box is highlighted and its contents will be copied to your clipboard.
Ctrl+T: This keyboard shortcut opens a new tab in internet browsers.
Ctrl+Shift+T: Reopens the last closed tab.
Ctrl+Shift+N: This shortcut opens a new incognito window in Google Chrome.
Ctrl+Shift+P: Opens a new private window in Mozilla Firefox.
Alt+Enter after writing the domain name in the address bar of your browser to insert .com automatically.
Shift+Enter inserts .net domain name extension.
Ctrl+W: This shortcut closes the current tab in your browser quickly.
Ctrl+Backspace: This shortcut deletes the last word you have typed. It is useful in case you typed in a wrong word and want to delete it quickly.
Ctrl+Left or Right Arrow key: This shortcut allows you to move the cursor one word at a time instead of the default one character at a time.
Ctrl++: This shortcut allows you to zoom in web pages in web browsers. Useful when text on a web page is too small to read properly. Ctrl+Scroll wheel can also zoom in documents, file thumbnails and icons in Windows 8.1, Windows 8, Windows 7 and Windows Vista.
Ctrl+-: This shortcut does the reverse of the previous shortcut.
Ctrl+0: Reset the webpage's zoom.
Windows key+M: Minimizes all the open windows.
Ctrl+L: This shortcut allows you to quickly jump to the address bar of your web browser.
Windows key+Pause/Break: Quickly open the system properties dialog box.
Ctrl+Shift+Delete: This shortcut opens the option to delete your browser's history, cookies, cache and other details that it stores while you browse the internet. This shortcut is extremely useful for the privacy conscious.
Windows Key+L: This shortcut locks your computer.
Ctrl+H: makes the history appear.
CTRL+B: Bold CTRL+U: Underline CTRL+I: Italic.
Alt+Select: This shortcut allows you to select rectangular blocks of text in Word processors, something that is not possible with simple select.
F2: Allows you to rename the selected file.
Holding Shift while inserting a device with removable storage prevents automatic run.
Ctrl+F: This keyboard shortcut opens the Find option in any program.
Ctrl+S: If you are working on a software and want to quickly save your progress, this shortcut will come in handy.
Ctrl+Home and Ctrl+End: Useful for quickly going to the top and bottom of a page.
Ctrl+P: Useful for printing the current page.
Space Bar: While viewing a web page in a browser, pressing space bar moves the page down.
Alt+Tab: Useful for quickly cycling between running applications. Press along with Shift to cycle backwards.
Ctrl+Tab: Cycle between tabs in your browser.
Ctrl+F5: Clears the cache and refreshes the current tab.
Shift+Right click: Open alternate right click options.
Alt+Double click: Open the file's properties. Alt+Enter can also be used for this.

These are some keyboard shortcuts that I found extremely useful. If you know some more useful keyboard shortcuts, do mention them in the comments.

Command prompt

Shutdown Your Computer or a Remote PC via Command Prompt
Hibernate a Local Computer
Type in "Rundll32.exe Powrprof.dll,SetSuspendState" without the quotes and press Enter. Your computer should hibernate, if it does not, then you must enable hibernation to do this.

Restart your Local Computer
Type "shutdown -r" in the command prompt and press Enter. In this case, the command switch -r is telling the computer to restart after shutdown.

Log Off the Current User
Type "shutdown -l" in the command prompt and press Enter. The -l command switch tells the computer to log off.

Shutdown a Remote Computer
Type "shutdown -s -m \\name of the computer" in the command prompt and press Enter. Replace \\name of the computer with the actual name of the remote computer you are trying to shutdown. As mentioned earlier, you must have administrative access to the computer you are trying to shutdown. To know if you have administrative access, press Windows key + R and then type the name of the computer and press Enter.

Shutdown your or a remote computer after a specific time
Type "shutdown -s -t 60" to shutdown your computer after 60 seconds. Upon executing this, a countdown timer displaying a warning message will be shown. This command uses the -t command switch followed by a variable (which is 60 in this case) which represents the number of seconds after which the computer will shutdown.

Display a Message containing the reason for shutdown
Type shutdown -s  -t 500 -c "I am tired. I don't want to work anymore." (with the quotes) in the Command Prompt and press Enter. The -c switch is used in the code to give the reason for shutting down and what is followed in quotes will be displayed in the dialog box as the reason. This can be used to display all sorts of funny messages.  

Stop a System Shutdown
Type "shutdown -a" and press Enter. This will stop the system from shutting down if the countdown to shut down has not reached 0

PC TALk

Cool Keyboard Tricks (Windows) : Make a Disco

Keyboards usually have small LEDs which indicate whether different types of locks are activated or not. Here is a trick to use the lights of your keyboard in a more creative manner in Windows.

This trick uses a simple Visual Basic Script which when activated makes your Scroll lock, Caps lock and Num lock LEDs flash in a cool rhythmic way which gives the perception of a live disco on your keyboard.


Keyboard tricks

To make your own live disco, follow the steps given below:-

1. Open Notepad.
2. Copy paste the exact code given below:-


Set wshShell =wscript.CreateObject("WScript.Shell")
do
wscript.sleep 100
wshshell.sendkeys "{CAPSLOCK}"
wshshell.sendkeys "{NUMLOCK}"
wshshell.sendkeys "{SCROLLLOCK}"
loop
3. Save the file as Disco.vbs or "*.vbs".



Cool Keyboard Tricks

Double click on the Saved file to see the LED lights on your keyboard go crazy and make your own cool disco.

Make your Computer Welcome You

NOTEPAD TRICKS

 NOTEPAD TRICKS

Notepad, the text editor that comes bundled in Windows is an excellent tool for text editing. But that is not the only thing for which notepad is famous. It is also famous for its tricks and hacks. Here is a roundup of some of the best and coolest tricks that you can try using Notepad.

Matrix Falling Code Effect 

Inspired by the movie Matrix, this falling code trick is extremely popular on social networking websites. Copy and paste the code given below in Notepad and save the file as "Matrix.bat".

@echo off
color 02
:tricks
echo %random%%random%%random%%random%%random%%random%%random%%random%
goto tricks

Matrix Falling Code Effect - Notepad Trick

Upon running the bat file, you will see the "Matrix falling code" effect.

Make Your Keyboard Type (Any) Message Continuously-VBS Trick

This VBS trick can make any of your friend's keyboard type any message continuously. Open Notepad, copy the code given below and save the file as Tricks.vbs or *.vbs. You will need to restart your computer to stop this. Try this after closing all important programs.


Set wshShell = wscript.CreateObject("WScript.Shell")
do
wscript.sleep 100
wshshell.sendkeys "This is a Virus. You have been infected."
loop
Send this file to your friends as an email attachment to see the fun.

Create a Harmless Funny Virus with Notepad-Continuously eject CD/DVD drives

This VBS trick will create a code which will continuously eject all your connected Optical drives. If you put them back in, it will pop them out again. Copy this code and paste it in Notepad as Virus.vbs or *.vbs.


Set oWMP = CreateObject("WMPlayer.OCX.7")
Set colCDROMs = oWMP.cdromCollection
do
if colCDROMs.Count >= 1 then
For i = 0 to colCDROMs.Count - 1
colCDROMs.Item(i).Eject
Next
For i = 0 to colCDROMs.Count - 1
colCDROMs.Item(i).Eject
Next
End If
wscript.sleep 5000
loop
 Double click to open this file and you will be impressed by this awesome trick.


Make a Personal Diary(Log) with Notepad (Easter Eggs)

Notepad Diary
Notepad Diary
You can use this trick to create a personal log with Notepad which will automatically include the current date and time before your note. To do so, open Notepad and type .LOG in capital letters and press Enter. Save the file. Now, every time you open this file, notepad will automatically insert the current time and date before the note. Just enter your note and save the file each time after making an entry.



Make your Computer Talk

Tuesday, 20 May 2014

IDEAL ICT CONTENT





NELSON ANJERE:

BUILDUP CONTENT FOR PROGRAMMERS AND SOFTWARE ENGINEERS.

I C T TUTORIALS


TROUBLESHOOTING YOUR MACHINE





Find out why....
Its good to have knowledge about how to trouble shoot your machine best on the work you do to avoid inconvenience or reliance on expert.To know this is very easy but under one condition....you must have passion to words it or else you might miss the point.Lets first look at the basic computer hardware so as to familiarize ourselves.
A computer system unit is the enclosure that contains the main components of a computer. It is also referred to as computer case or tower.
       A typical desktop computer consists of a computer system unit, a keyboard, a mouse, and a monitor. The computer system unit is the enclosure for all the other main interior components of a computer. It is also called the computer case, computer chassis, or computer tower. Cases are typically made of steel or aluminum, but plastic can also be used. While most computer cases are rather dull, black, metal boxes, some manufacturers try to give the unit some flair with color and special design elements.

FUNCTIONS 
        The primary function of the computer system unit is to hold all the other components together and protect the sensitive electronic parts from the outside elements. A typical computer case is also large enough to allow for upgrades, such as adding a second hard drive or a higher-quality video card. It is relatively easy to open up a computer system unit to replace parts and install upgrades. In contrast, it is quite difficult to open up a laptop computer, which is not designed with replacements and upgrades in mind.
In most computer system units, the front side contains the elements a user needs frequently, such as the power button, an optical disk drive, an audio outlet for a pair of headphones, and a number of USB connections. The back side contains all other connections - for power, monitor, keyboard, mouse, Internet connection, and any other peripheral devices. There are typically more connections than the minimum necessary to allow for expansion. 
COMPONENTS FOUND ON THE MOTHERBOARD

In this particular example, the motherboard is placed vertically, which is quite common. One side of the motherboard is accessible from the back of the computer case - this includes the various connectors for input and output devices as well as expansion slots for additional peripherals. The motherboard also contains the central processing unit (CPU), although it can be difficult to see. A large fan is often placed on top of the CPU to avoid overheating. The motherboard also contains the main memory of the computer.
      The motherboard Is the basis of your computer. It's the first component installed in the system unit, and it holds all of the circuitry that ties the functions of the computer components together.

Central Processing Unit

 

The motherboard and circuitry need to have power. There is a power box included with your system unit, and you'll see a cord coming out of the back of your computer for that.  
The central processing unit, or the brains of the computer, sits on the motherboard and does actually have its own cooling fan. The processors now are so fast they need to be cooled down. All the instructions you give the computer - like a click of a mouse - go through the CPU, which processes in billions of cycles per second.   Commonly installed processors have quad-cores, or four separate processors in one component. There are six-core and eight-core available, and the more advanced the technology the higher the       cost. That's one of the    choices you might need to make. 

Memory, Cache, RAM, ROM

 

Next to the CPU sits the cache, or the temporary memory where things you are working on sit for quick interpretation by the CPU. The RAM chip is also near this location. Random-access memory is volatile, or temporary, memory. Whenever you turn on a program, its instructions are stored in RAM while the machine is on. Once you shut the machine down, both the cache and the RAM are completely cleared out. RAM storage is common at eight, ten or twelve gigabytes.
ROM, or read-only memory, is located here as well. This is a permanent, or non-volatile, memory. As soon as you turn on your computer, the start-up instructions that are stored in ROM begin to execute. Even when you turn it off, the instructions stored in ROM remain. So if you have a machine that runs Windows, as soon as you hit the power-up button, you'll get a short screen that might give you a message from the manufacturer. Then in the background you'll just see black and the Windows logo come through, and it will say 'Starting Windows.' What's going on there is that as soon as you hit the power button, your ROM is kicking in and starting up all those instructions for systems checks.
The part attached to the motherboard you're most likely to recognize is the hard drive




The hard drive doesn't sit directly on the motherboard, but it is connected to the circuitry by electrical wire. The hard drive stores software you've put in there like Firefox, Word Pad or a music player. It also stores the data files those programs have created and used. Hard drive storage commonly begins at one terabyte now and goes up to two and a half terabytes. 
  
Video and Sound Cards

Lets learn about the video card, or the graphics card. This card is used to process images so you can see them on your computer. As a standard computer user, the video card included with the system you are looking at will suffice. If you are a gamer, or really into working with photos or digital art, you may be looking for higher-end cards. These cards are more expensive, but typically have their own CPU for better and faster processing of images. Many video cards now allow for more than one monitor to be hooked up to the system.

Thursday, 1 May 2014

COMPUTER MATHS


QUALITATIVE MATHEMATICS



MEASURES OF CENTRAL TENDENCY

Arithmetic Mean

This is the average of any given observation e.g 8,4,9 will be
8+4+9/3=7
For a grouped data mean is calculated as
Mean = Efx/Ef
E = sum of
f = frequency
x = midpoint

Other types of mean include;
Geometric mean;
This is the nth root of the products of numbers i.e
5,2,1,3
(5*2*1*3)*1/4=2.34

Harmonic mean;
This is the reciprocal of arithmetic mean of reciprocal of numbers of items.i.e
1/x+1/x+1/x)/3

Median
This the middle value of any given observation.When the data is arranged in ascending or descending order it is calculated as follows;
9,6,5,7,1
1,5,6,7,9
6 is the median because is the middle value.

For a grouped data mean is calculated using the following formula;
L+(C1/2N-CF)*F Where;
L=lower class limit.
N=sum of frequency column.
CF=cumulative frequency before median class.
F=frequency of median class.
C=median class size.

Mode.
This is the most frequent number in any given observation i.e
6,4,8,4. mode is = 4.
For a grouped data mode is calculated as follows;
L+(F1-F0)/(2F1-F0-F2) Where;
L = lower class limit of modal class.
F1 = highest frequency.
F0 = frequency before f1.
F2 = frequency after f1.
C = modal class size.

N/B;
Modal class is the class with the highest frequency.
Histogram.
This is a diagrammatic representation of information in order to determine the mode.(frequency against upper class limit)

Measures of Dispersion.


This analyses how data is spread from measures of location. i.e Arithmetic mean.
There are varies measures namely;
Range.
Variance and standard deviation.
Co-efficient of variance
Quartiles.

Range
This is the difference between the highest value and the lowest value.
Variance.
This is the mean squre deviation.It is calculated as follows;
Variance = E(X-MEAN)/N;N =number of items.

Standard deviation;
This is the squreroot of variance.
Co-efficient of variance;
This is the ratio between standard variation and the mean.It is a measure of risk to any business,
Quortiles.
This is a distribution which is divided into for equal parts.
lower quartile
L+(1/4N-CF)F)*F

Upper quartile

L+(3/4N-CF)/F)*C.

Quartile deviation
This is the difference between upper quartile and lower quartile.
Semi inter quartile range
This the quartile deviation divided by two
Ogive;
This is a cumulative frequency curve which is drawn to estimateQ1,Q2 and Q3 as follows.


Measures of skewness

This is evaluation and analysis of degree of symmetry.
There are three types of analysis namely;
Normal distribution
positive skewness
Negative skewness

Normal distribution(Gausian Distribution)


This arises when the mean and the mode are equal.
Properties of normal distribution
Its bell shaped
The three measures of central tendancy are equal.
Has a standard deviation of one.
Its explained a symbol of Z
positive skewness
It arises when mode is greater than mean.
negative skewness It occurs when mean is greater than mode.
In order to determine skewness the following formula's are used

Formula 1;
s.k=3(mean*median)/standard deviation.
Formula 2.
s.k=(Mean-mode)/standard deviation

Interpretation
If we use the above formula and you get a 0 then it means their is a normal distribution
If the answer is positive it means their is a positive skewness.
If the answer is negative it means their is a negative skewness.
CORRELATION
Its the existence of relationship between two variables or the degree of relationship between two variables.
TYPES OF CORRELATIONS
Positive correlation
An increase in one variable leads to an increase in the other variables i.e
Increase in price leads to an increase in quantity supplied
Increase in advertisement leads to an increase in sales
Negative Correlation
an increase in one variable leads to a decrease in the other variable i.e
An increase in price leads to a decrease in quantity demanded
Spurious Correlation
This is the relationship between many variables.It is also called Non-sense correlation .
The degree of relationship is determined by two co-efficients as follows.

Spear-sons Moment co-efficient of correlation.
R=N{xy-{x{y/([n{x*x-{(x)*(x)]*[n{y*y-{(y*y))*0.5
Where;
n=Number of items
x=In depended variables(x axis)
y=Depended variables(y axis)


  • spears man rank co-efficient of correlation.



  • This is used to establish relationship between two variables,especially when ranking of items when necessary.
    The following formula is applied


    r=1-(6{d*d/n(n8n-1))

    D=Difference between ranks
    n=Number of items

    REGRESSION

    This is the nature of relationship between variables.The nature of relationship is determined by regression line equation.(line of best fit)
    This is the general form y=a+bx
    y=Dependant variables
    x=Independent variables
    a=Constant(fixed cost)
    b=gradient which represents variable cost per unit
    Types of Regression
    Simple linear Regression
    It has one in depended variables(x) of general formula.
    y=a+bx
    Multiple Linear
    It has many independent variables of general formula
    Y=a+bx+bx+bx
    The value of b and a in simple Linea regression is determine as follows;

    b=n{xy-{x{y/n{x*x-{(x*x)
    a={y-b{x/n.

    Co-efficient of Determination(r*r)
    In depended variables can be used to explain independent variables.it is used to show by how much dependent variables rely on independent variables.it is calculated by squaring co-efficient of correlation as follows;
    r*r=(n{xy-{x{y/(n[{x*x-{[x*x]]*[n{[y*y]-{[y*y]])squire
    Time Series
    This is a mathematical technique used to predict the trend.This is the observation which has been their for a very long period period of time.
    Components of Time series.Thi is the characteristics of the time series namely;
    Secular Trend 'T'
    Seasonal Variation 'S'
    Random Variation 'R'
    Cyclic Variation 'c'

    Secular Trend;This is the observation seen over long period of time.i.e increase in prices of commodities
    seasonal variation;This are the observation seen over long period of time.
    Random variation;This are things which are beyond human control and they occur as a result of state of nature.
    Cyclic variation;this is variation normally seen in business trade cycle.
    During boom phase their is high sales,high profits and high employment levels.
    During races their is losses,no sales and high unemployment level.

    Methods of fitting a Trend line

  • Semi-average
  • Least square equation method
  • Moving average method
    N/BThe line of best fit (Regression line equation) is used to predict line values
    i.e Y=a+bx
    b=n{x*y-{x{y/n{(x*x)-{(x*x)
    a={y-b{x/n
    Deseosonalization of time series

  • This is the removal of seasonal variation from the other components of time series.
    Their are two major methods used for this technique;

  • Additive model
  • Multiplicative model
    Additive model
    Under this we sum up the four components of time series e.g
    Secular + Random + Cyclic + Seasonal components.
    Under additive model,the trend values are subtracted from the actual values in oder to remove seasonal variation
    N/B Additive model is applied when the four components of the time series are independently from one another.
    Multiplicative model.
    Under this model the four components of time series are multiplied i.e
    Seasonal*Random *Secular.
    In order to determine seasonal variation using multiplicative model the actual values are divided by trend line values.,br> 
  • N/B 
  •  The model is applied when the four components of time series are depended of one another.

    This are numbers that illustrate changes in prises

  • Simple price index is calculated as follows;
    Simple price index=(p1/p0)*100%
    Where;
    p1=Price in the current year
    p0=Price in the base year
    weighted
    The weight of a given commodity is combined with prices.
    Their are three types of weighted index namely;

  • Lasypyres index number
  • paasches index number
  • Fishers ideal index number.
    Lasypyres index
    this uses the base year as the weight.
    There are two types of Lasypyres index namely;
  • Lasypyres price index
    ={(p1q1/p0q0)*100%
  • lasypyres quality index;
    ={q1p0/q0p0)*100%
    Where;
    p1=Price in the current year.
    p0=Price in the base year.
    q1=Quantity in the current year.
    q0=Quantity in the base year
    Paasches index
    This uses the current year as the weight.
    it is of two types namely;
  • Paasches price index
    ={(p1q1/p0q1)*100%
  • Paasches quantity index
    ={(q1p1/q0p1)*100%
    Fishers ideal index
    This is quadratic mean between Lasypyres index and Paasches index as follows;
  • Fishers ideal price index;
    (Paasches pirce index*Lasypyres price index)*0.5
  • Fishers ideal quantity index;
    (Paasches Quantity index*Lasypyres quantity index)*0.5
    Network Analysis
  • Thursday, 24 April 2014

    VISUAL BASIC PROGRAMMING


    Characteristics of Visual Basic
    Is not case sensitive
    Logics and operations are unified
    It support the use of objects
    Can create executable files.
    Statements are terminated by keyword "End if"
    Definition of terms:

    Data Types;Are set of data with values having predifined characteristics.
    Variables;Is a named memory location used to store values but keep on changing during program execution
    Constants;Is a named memory location that stores values but do not change during program execution.
    Identifies;Are names given by. Programmers to objects in a program.
    Rules governing the naming of identifies.
    It should be less than 255 characters.
    It should not be a keyword or reserved word.
    It should always begin with an alphabet.
    It should not contain blank spaces.
    It should be unique within given slope.
    Visual basic is said to be event driven because;
    All or majority of the code happens as a result of something else,which is an event.

    Messages and Input boxes.
    A message box has three parts namely;
    Prompt;Is a message of a message box.
    Tittle;Is the tittle of the message box.
    Helpfile and Context;Is where in a helpfile a user can find help from that message box.
    Parts of the input box:
    title Prompt;This is the message that input box has.It tells the user what the program wants them to input.
    s:
    Data Types;Are set of data with values having predified characteristics.
    Variables;Is a named memory location used to store values but keep Post titlechanging during program eecution
    Constants;Is a named memory location that stores values but do not change during program eecution.
    Identifies;Are names given by. Programmers to objects in a program.
    Data Types in Visual Programming

    Avariable:
    Is a named memory location that holds data
    It can hold only one data type i.e String,Integer.A program may have as many variables as you need but it has to be declared before being used.We use Dim statement to declare variables.
    Formattof declaring variables using a Dim
    Dim Var Name As Data type i.e
    Dim curcost As currency.
    Dim strsurname as String
    Function;Is a segment of codes that accepts one or more arguments and return a 0 results.
    Visual basic include many build in functions.
    Intrinsic functions;Some perform basic mathematical task while others manipulate string data such as converting text to upper or lower case letters.
    Arguments;Is a value passed to a function so that a function has data to work with.
    N/BProperty of a label are;Name,Caption and color.Label caption(object property)="Welcome to visual basic"(option property).
    An object;Is anything that appears on the screen.It has a set o properties and each property has a set of values.
    Events;Are things that happen on the screen.
    Procedure;Is a group of statement design to perform a specific task.
    Quiz
    Design a form containing 2 text box so that when you click on command button copy,the text is copied from 1st to 2nd text box.
    Hint 1label,1 text box and 1 command.
    Private sub command-click()
    Text2.text=Text1
    Texr2.font size=28
    End sub.


    Option button;
    It is used only as a group of buttons.When the user select one of them,the others are deselected automatically.The option button usually takes click event.
    Quiz
    Design a form with 3 option button,Red,Green and blue,such that when we click on option button, the color of the form colors to red,green and blue respectively.
    Hint;
    3 option buttons with 3 labels.

    Private sub option-click()
    Form.back color=vb green
    End sub.
    Private sub option-click()
    Form1.back color=vb red
    End sub.
    Private sub option-click()
    Form1.back color=vb blue
    End sub.



    Text Box


    De sine a form with one text box and three check boxes such that when you click on the check boxex the following is done.Change text to bold,italics and underline.
    private sub check1.click()
    text.font bold=check2.value
    End sub.
    Private sub check2.click()
    Text.font italic=check2.value
    End sub.
    Private sub check3.click()
    text.font underline=check3.value
    End sub.

    Timer
    It returns the time in milliseconds.It may be used to measure execution time of codes(program efficiency)
    Design a form to display "Aplied Science"such that when you click on "command button"start the color of the applied science change randomly every second.
    Hint;Timer,label,command button.
    The function "Cint"is used to convert to integer and "Rnd" is used to generate Armando number in a range(0-1).
    Solution;
    Private sub timer_timer()
    t=Rnd*15
    label1.fore color=qbcolor(Cint(t))
    End sub.
    Private sub command1.color check()
    timer.Enabled=True
    End sub.
    .
    Write a program to move text excellent from textbox to msgbox and change the color of the text.After click on command button display.
    Hint;
    1 textbox,1 command button.

    msgbox(.text1.text)
    text1.back color=qbcolor(g)
    text1.text=" "
    End sub.
    Functions
    Description

    Absolute(abs)(x) Absolute of x
    Squre(sqr)(x)Squreroot of x
    Integer(int)Integer of x
    Exponential(exp)(x) Exponential of
    Fixation(x)Take integer part
    Sin (x)Cos(x)Tan(x)=0Trigometric functions
    Log(x)Natural logarithms
    Len(x)Number of characters of variable x
    Lcase(x)Change text x to upper case
    Ucase(x)Change text x to lower case
    Cint(x)Convert x to integers
    ClongxConvert x to long
    Cdbl(x)Convert x to double precission
    Cstr(x)Convert variable x to string
    val(x)Convert string x to numerical value.
    Write a program to enter any text and compute its length.
    Hint;
    1 label,1 textbox and 1 command button.

    Dim S As string
    Private sub command1_click()
    S=input box("Enter String")
    L=len(s)
    Text1.text=(str(l)
    End sub.

    Write a program to add and subtract 2 integer numbers.Use messagebox for outputting.
    Hint;
    2 labels,2 text boxes and 2command buttons.

    Dim x,y,z as integer
    Private sub command1_click()
    x=val(text1.text)
    y=val(text2.text)
    z=x+y
    msgbox("Addition results="&z)
    End sub
    Private sub command2_click()
    x=val(text1.text)
    y=val(text2.text)
    z=x-y
    msgbox("subtraction results="&z)
    End sub


    dim x,y,z AS integer
    Private sub command1_click()
    x=val(text1.text)
    y=val(text2.text)
    z=x+y
    Text3.text=z

    A program that compute a function sine,cosine,integer value,squre and the absolute value.
    Hint1 text box and 6 command buttons.

    Dim x,y As String
    Private sub command1_click()
    x=val(text1.text)
    y=Abs(x)
    Text1.text=Cstr(y)
    End sub
    x=val(text1.text)
    y=sqr(x)
    text1.text=Cstr(y)
    End sub
    Private sub command3_click()
    x=val(text1.text)
    y=int(x)
    text1.text=Cstr(y)
    End sub
    Private sub command4_click()
    x=val(text1.text)
    y=sin(x*3.114159/180)
    text1.text=Cstr(y)
    End sub

    A program that allows the name of a student and two marks of any subjects by input box then compute the average and display the name and average in two labels.
    Hint
    two labels and one command button.

    Dim x,z,y As string
    Private sub form1_load
    x=input box("Enter your name")
    y=input box("Enter the 1st marks")
    z=input box("Enter the 2nd marks
    Private sub command1_click
    Av=val(y0/2+val(z)/2
    Lbel2.caption=Av
    End sub.
    A program that compute the area of a triangle.
    Hint
    Area=1/2*b*h
    Two labels,one text box and one command button.

    Dim a,b,h,As string
    Private sub command1_click()
    b=val(text1.text)
    h=val(text1.text)
    a=0.5*b*h
    msgbox("area="&a)
    End sub.
    A program that displays the time and the date.
    Private sub form_Load()
    Ladel.caption=Time value(now)
    Label2.caption=Date value(now)
    End sub