Download presentation
Presentation is loading. Please wait.
1
Computers & Programming Languages
4
10+2 12 10+2 = 102 10+2 = 12 10+2 = 12 Twelve
5
Lesson4- Objectives Identify data types Identify identifiers Use identifiers to name memory cells Select the appropriate data type
6
Containers that store data (numbers & letters) in the program.
Variables Containers that store data (numbers & letters) in the program. Modern Cars Modern Calculators
7
Data Type Variable Name ;
Declaration of Variables Data Type Data Type Variable Name ;
8
Data Type أنواع البيانات
Activity Answer the following questions What’s your name ? Your Age ? Your weight ? / selected question What is the value of PI ? Are you interested to travel abroad to complete your study ?
9
Data Type أنواع البيانات
Primitive Data Types integer byte short int long Floating Point float double character char Boolean boolean
10
Data Type / Integer Data type int is the commonly integer type used in programming
11
Data Type / Floating Point
Data type double is the commonly floating point used in programming Book Activity Page 170
12
Practical Activity Variable name
Open a new java project name (lesson4-1) Variable name
13
Identifiers consists of A-Z, _ , $ , numbers
Variable identifiers (Name) Identifiers consists of A-Z, _ , $ , numbers Identifiers should not start with numbers Identifiers are case sensitives Some words should not be used as identifiers : Boolean, byte, class, double, float, public , void ….etc Illegal identifiers ( 123abc, Book Activity Page 171
14
Activity in your book P-172
15
Activity in your book P-172
Find Errors & correct them: Declaration Error Correction int num1 Missing ; int num1; duoble price; double (spelling mistake) double price; Int area; Int (spelling mistake) int area; int double; Reserved word double int d; int 3age; 3age int age3;
16
Activity / group work An employee earns a basic salary of 5500 AED, transportation 1200 AED, housing allowance 200 AED. Write an algorithm and then create a java program to calculate his total salary. program int num1,num2,num3,total; num1 = 5500; num2 = 2000; num3 = 1200; total = num1 + num2 + num3; System.out.println ( "total =" + total); Algorithm Get basic salary, transportation, housing allowance. Find total salary = basic salary + transportation + housing allowance. Print total salary
17
Activity in your book P-172
Create java program that declares two variables which represent your grade and average program int grade; double average; grade = 10; average = 90.5; System.out.println ( “grade is " + grade); System.out.println ( “average is " + average); 5 Minutes
18
Activity in your book P-172
Suppose that ahmed bought a new smartphone from an electronics shop and that he got 12.5% discount on his purchase. Create a java program to declare the variables. program int price; double discount , Total; price= 2500; discount = 0.125; Total = (price - (price*discount)); System.out.println ( “Price after dsicount" + Total); 5 Minutes
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.