Professional Documents
Culture Documents
SSS 2
SECOND TERM
SCHEME OF WORK
WEEKS TOPICS
1. Introduction to Computer Data Conversion I
2. Computer Data Conversion II
3. Security and Ethics
4. Concept of Computer files
5. Concept of Computer file
6. Handling Computer Files
7. Handling Computer Files
8. Handling Computer Files
9. Java Console Input 1
10. Java Console Input 11
11. Java Control Statement 1&2
12. Revision
13. Examination
WEEK: 1
DATE: ………………………………………………………….
CLASS: SS2
TOPIC: INTRODUCTION TO COMPUTER DATA CONVERSION
REGISTER
Definition of register
Register is one of a small set of data holding places that are part of a computer
processor
Almost all computer load data from a larger memory into registers where it is
used for arithmetic, manipulated or tested by some machine instruction
Address
Bus
MAIN PROCESSOR
MEMORY BUS
BUS
Types of Bus
The Internal (or System) Bus resides on the mother board and connects the CPU
to other devices that resides on the motherboard. Examples are :
WEEK: 2
DATE: ………………………………………………………….
CLASS: SS2
TOPIC: COMPUTER DATA CONVERSION II
COMPUTER DATA CONVERSION
Types of register
Register are normally measured by the number of bits they can hold, e.g. an 8-bit
register, or a 32-bit register.
There are various types of register those that are used for various purposes.
Holds truth values often used to determine whether some instruction should or
should not be executed
can store both data and addresses , i.e. They are combined Data / Address
register
Hold program state; they usually include the program counter and status
register. Differences between register and main memory
The Data - Fetch – Execute Cycle is the process, by which a computer retrieves
a program instruction from its memory, determines what actions the
instructions require and carries out those actions.
The Circuits used in the CPU during the fetch execute cycle are:
a) Program counter (PC)
b) Memory Address Register (MAR)
c) Memory Data Register (MDR)
d) Current Instruction Register(CIR)
e) Control Unit (CU)
f) Arithmetic Logic Unit (ALU)
Start
Load address to PC
Set PC to
Jump YES
value from
?
NO jump
Execute instruction
NO YES
Interrupt Service
? interrupt
SECURITY BREACHES
COMPUTER SECURITY
PREVENTIVE MEASURES
LEGAL ISSUES
The following are legal issues related to the use and misuse of ICT
A file holds data which is required for providing information. It resides on the
secondary (auxiliary backing) storage such as magnetic disk
RECORD
FIELD
DATA ITEM
FILE
RECORDS
RECORDS
RECORDS
The key enables user to access specified records without going through the
entire file.
a. Sequential Access
b. Serial Access
c. Random Access
d. Indexed Sequential Access
a. Sequential Access
b. Serial Access
Serial access means that in order to identify and retrieve a particular record
it is necessary to read all the records which precede it in a relevant file.
c. Random Access
The random access sometimes called direct access is the ability to access
an element at an arbitrary position in a sequence in equal time,
independent of sequence size.
The main concept is to access a file directly first and then sequentially
from that point onwards.
It is a method of indexing data for fast retrieval. It is in fact a combination
of both the sequential access as well as random access
Assignment
List three types of data item with suitable example
WEEK: 5
DATE: ………………………………………………………….
CLASS: SS2
TOPIC: CONCEPT OF COMPUTER FILES
SUBTOPIC: CLASSIFICATION OF COMPUTER FILES
FILE CLASSIFICATION
Computer files are classified into the following
1. Master file
2. Transaction file
3. Reference file
1. MASTER FILE
It is a computer file containing relatively permanent information, usually updated
periodically, such as payroll data, names, etc.
Master file contains records of permanent records and data.
2. TRANSACTION FILE
It contains data which is used to update the records of master file. E. g.
address of the customer. It is a collection of transaction records e.g sales
transaction file may contain details of all sales made a day, a week, a month or
more . it also serve as audit trail and history.
3. Reference file.
It is a file that is used for reference or look up purpose.
Assignment
1. State two limitation of computer filing system
WEEK: 6
DATE: ………………………………………………………….
CLASS: SS2
TOPIC: HANDLING OF COMPUTER FILES
4. Copy: To produce, duplicate, or create a new file which has the same content
as an existing file
8. Close: To close, or make the content of a file not available for viewing
Sequential files
In sequential files, to find a particular element, you must first read the whole file
up to that element. It is also a file whose record is organized on the basis of their
successive physical portion.
Sequential file are files which consist of the same record types that are stored on
a secondary storage device.
3. Close the file: The CLOSE statement closes a file after the program has
completed all I/O operations
4. CLOSE # : To close the file after the process has been completed.
WEEK: 7
DATE: ………………………………………………………….
CLASS: SS2
TOPIC: HANDLING OF COMPUTER FILES
SUBTOPIC: FILE INSECURITY
FILE INSECURITY
File insecurity refers to the concept that computer system file is always
vulnerable to attack
The attack usually is on files personally created by user or files created during
installation of our computer system and other packages we make use of. These
fact create a constant battle between those looking to improve security, and
those looking to circumvent security.
1. Data/information loss
Data loss is one of the major problems associated with computer files,
coincidentally. It is one of the problems computer system hope to achieve from
the old files storage system.
Therefore, adequate care must be taken to ensure that computer files are well
secured and void of loss or damage.
It occurs most times when we are careless with naming our document. This
happens when a new file is created. We try to save it but we are not careful
enough to check if such name exists before. If we eventually save with the name,
it overwrites the existing document even though they do not contain information.
3. Data Corruption
1. Use of back-ups: This is coping or creating the copy of your file in another
storage medium, so that if any damage occurs the file can be replaced from the
backup.
They are mostly refers to as utility programs and they help to block and clean-up
threats to computer files
4. Proper labelling of storage devices: Storage device should be well labeled, this
makes it easier to store and locate file, it also prevent accidental and form of
storage devices.
WEEK: 8
DATE: ………………………………………………………….
CLASS: SS2
TOPIC: HANDLING OF COMPUTER FILES (cont’d)
2.Computer file allows operations or Manual file system does not support
transactions like insert, delete, such operation or transaction.
update, etc.
3. It is expensive to set up
WEEK: 9
DATE: ………………………………………………………….
CLASS: SS2
TOPIC: JAVA CONSOLE INPUT 1(USING KEYBOARD CLASS)
char charInput
In the above example, the string “enter a character” prints on the screen. A message
charInput=(char)System.in.read():
requesting user input is commonly known as a prompt because it prompts or coaches
System.in.read();System.inread();//absorbs the enter key.
the user to enter an appropriate response. The System.in.read() is used to obtain a
character
Input entered by the user the keyboard. The read() method accepts the returned integer
into a character. The cast(char) converts the returned integer into a character.
By default, the standard input is line buffered, so the Enter key must be pressed before
any characters that we type will be sent to the our program.
There is however, a problem when we use read() to accept a character from the
keyboard, every key we press – including the Enter key – is accepted, one at a time.
Thus, we can absorb the Enter key after each input by reading in with two read()
method cells.
Since we are using the System.in.read() method, in the main() method header, a phrase
throws Exception must be added at the end of the line. It is necessary to handle input
errors. An exception is an error situation. Because errors should be infrequent, and all
sorts of errors can arise, thus, we can let the compiler handle the problem by throwing
the exception, or passing the error to the operating system. By placing throws Exception
after the main() header accomplishes this and a program, which reads keyboard input
will not be able to compile successfully without this phrase.
In Java programming language, the terminal window is used as the standard output.
System.out is a PrintStream object that allows us to write to “standard output” there are
two methods used in Java programming language that allows the users to display the
input that had been entered to the screen, which include the print() and printIn() method.
The difference between the two methods was mentioned in the earlier chapters. By
using the printIn() method, after a statement is displayed, the cursor will be position on
the next line. If the print() method is used, the cursor will be position on the next
available position but on the same line.
WEEK: 10
DATE: ………………………………………………………….
CLASS: SS2
TOPIC: JAVA CONSOLE INPUT II
The Scanner class is used to get user input, and it is found in the java.util package.
To use the Scanner class, create an object of the class and use any of the available
methods found in the Scanner class documentation. In our example, we will use
the nextLine() method, which is used to read Strings:
Example
class Main {
System.out.println("Enter username");
}
Input Types
In the example above, we used the nextLine() method, which is used to read
Strings. To read other types, look at the table below:
Method Description
In the example below, we use different methods to read data of various types:
Example
import java.util.Scanner;
class Main {
// String input
Run Example »
Note: If you enter wrong input (e.g. text in a numerical input), you will get an
exception/error message (like "InputMismatchException").
You can read more about exceptions and how to handle errors in the Exceptions
chapter.
WEEK: 11
DATE: ………………………………………………………….
CLASS: SS2
TOPIC: JAVA CONTROL STATEMENTS 1&11
Selection statement allows our program to choose different paths of execution based on the outcome
of an expression or the state of the variable. The expression or value upon which a decision is made is
always a boolean value, which is always one of two values – true or false. Java supports two kind of
selection statements: if or if..else statement and the switch statement.
THE IF-STATEMENT
statement 1;
statement 2;
...
'Statement n' can be a statement or a set of statements, and if the test expression evaluated
to true, the statement block will get executed, or it will get skipped.
if(b>a)
System.out.println("b is greater");
Program Output:
Java Switch Statements
Use the switch statement to select one of many code blocks to be executed.
Syntax
switch(expression) {
case x:
// code block
break;
case y:
// code block
break;
default:
// code block
Example
int day = 4;
switch (day) {
case 1:
System.out.println("Monday");
break;
case 2:
System.out.println("Tuesday");
break;
case 3:
System.out.println("Wednesday");
break;
case 4:
System.out.println("Thursday");
break;
case 5:
System.out.println("Friday");
break;
case 6:
System.out.println("Saturday");
break;
case 7:
System.out.println("Sunday");
break;
}
Try it Yourself »
This will stop the execution of more code and case testing inside the block.
When a match is found, and the job is done, it's time for a break. There is no
need for more testing.
A break can save a lot of execution time because it "ignores" the execution of
all the rest of the code in the switch block.
Example
int day = 4;
switch (day) {
case 6:
System.out.println("Today is Saturday");
break;
case 7:
System.out.println("Today is Sunday");
break;
default:
System.out.println("Looking forward to the Weekend");
Try it Yourself »
Note that if the default statement is used as the last statement in a switch
block, it does not need a break.
int day = 2;
switch ( ) {
1:
System.out.println("Saturday");
break;
2:
System.out.println("Sunday");
;
}
Nest if and Nested if…else Structure.
We can code as many dependent statements as we need within an if or an else statement. Such
statements with an if inside another if are commonly called nested if statements. Nested if statements
are particularly useful when two conditions must be met before some action is taken.
If (condition 2)
Statement;
If(condition 1)
If(condition 2)
Statement 1:
Else
Statement 2:
The example below shows a segment of a program using the nested if statement.
If ( itemSold > 3)
The next example below shows a segment of a program using the nested if…else statement.
If (itemSold >3)
Bonus = 50;
Note: There can be sometimes when there will be more than one action taken place (compound
statements) following by the evaluation of a Boolean expression within an ifstatement. To execute more
than one statement that depends on the evaluation of a Boolean expression, we will have to place these
compound statements within a pair of curly brackets.