btec unit 06 – lesson 06 evidencing p4 mr c johnston ict teacher

8
BTEC Unit 06 – Lesson 06 Evidencing P4 Mr C Johnston ICT Teacher www.computechedu.co.uk

Upload: theodore-golden

Post on 12-Jan-2016

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: BTEC Unit 06 – Lesson 06 Evidencing P4 Mr C Johnston ICT Teacher

BTEC Unit 06 – Lesson 06

Evidencing P4

Mr C JohnstonICT Teacher

www.computechedu.co.uk

Page 2: BTEC Unit 06 – Lesson 06 Evidencing P4 Mr C Johnston ICT Teacher

Session Objectives Understand different data types there formats and use Be able to use the correct data type for a variable

storing a specific value, Understand the grading requirements of P4.

Page 3: BTEC Unit 06 – Lesson 06 Evidencing P4 Mr C Johnston ICT Teacher

Data Types???

Page 4: BTEC Unit 06 – Lesson 06 Evidencing P4 Mr C Johnston ICT Teacher

Data Types We know from lesson 05 that every variable needs to

be assigned a data type, The data type sets the type of data which will be

stored within it and the range of values it can accept and how the data will be formatted when displayed,

Although data types vary from programming language to programming language most support similar ones,

The next slide shows some of the data types which are supported in visual basic.

Page 5: BTEC Unit 06 – Lesson 06 Evidencing P4 Mr C Johnston ICT Teacher

Visual Basic Data Types

Data Type Data Use Range of Values

Boolean Values that can be true or false

True or False

Byte Whole numbers (8 bit) 0 to 255

Integer Whole numbers (16 bit) -32,768 to +32,767

Long Large whole numbers c +/- 2x109

Single Decimal numbers (float) Up to 7 significant figures

Double Large decimal numbers Up to 14 significant figures

Currency Number formatted to 2DP

Date Date and Time Variety of date and time formats

String Any type of character Sometimes char limit

VbMsgBoxResult

Results of msgbox button presses

vbYes, vbNo, vbOK, vbCancel etc

Page 6: BTEC Unit 06 – Lesson 06 Evidencing P4 Mr C Johnston ICT Teacher

Choosing Data Types Assigning the correct data type to a variable is

important for example: Choosing a data type with a capacity to store more data than will

ever be required is wasteful, Choosing a data type that is too small for the value being stored can

crash the program, Text cant be stored in numerical data types however any characters

can be stored in strings, Numerical data cant start in a 0 as its breaks the rules of maths

learnt at primary school, If you need to perform calculations and comparison of numerical data

then its cant be stored as text, If a data item is to be used in different parts of the program then its

type needs to be consistent, Code can be used to change the data type of a

variable e.g. cint(variable) or clng(variable) or cstr(variable)

Page 7: BTEC Unit 06 – Lesson 06 Evidencing P4 Mr C Johnston ICT Teacher

Evidencing P4 P4 asks you to produce some further slides in your

presentation which explain why different data types are needed and the benefits to programmers of having a range of data types to work with,

Start off by explaining the different data types available and what each is used for – include some sensible examples,

Think about the space occupied for each and why it might be useful compared to other types,

Make a comment about which data types seem to be common in different programming languages and which are proprietary,

Write a some notes which explains why it is important to choose the correct data type and some of problems if the programmer gets it wrong.

Page 8: BTEC Unit 06 – Lesson 06 Evidencing P4 Mr C Johnston ICT Teacher

• A written response for P4 may be appropriate, or a table with perhaps three or four columns: data type, example, space occupied and comment.

• The data types available may be different according to which language is chosen, however there is an expectation that learners know of the wider range of data types available, six would be sufficient.

P4 – explain why different data types are needed in programs and describe the benefits of having a variety of data types available to the programmer

P4 – explain why different data types are needed in programs and describe the benefits of having a variety of data types available to the programmer

Visual Basic Data Types:http://msdn.microsoft.com/en-us/library/47zceaw7(v=vs.80).aspxJava Data Types:http://www.tutorialspoint.com/java/java_basic_datatypes.htmC++ Data Types:http://www.tutorialspoint.com/cplusplus/cpp_data_types.htmPascal Data Types:http://www.tutorialspoint.com/pascal/pascal_data_types.htm