Download presentation
Presentation is loading. Please wait.
Published byDominic Strickland Modified over 8 years ago
1
UFCFY5-30-1Multimedia Studio Coding for Interactive Media Fundamental Concepts
2
UFCFY5-30-1Multimedia Studio Agenda Basic Process Variables and Data Types Assignment of Variables Output of Results and Formatting Coding Exercises.
3
UFCFY5-30-1Multimedia Studio Basic Computer Program Input Process Output.
4
UFCFY5-30-1Multimedia Studio Computer Program Steps Input (input the data) Process (process the data) Output (display the results).
5
UFCFY5-30-1Multimedia Studio Example: Program That Adds Two Numbers Input (first number, second number) Process (add numbers together) Output (display the results).
6
UFCFY5-30-1Multimedia Studio Example: Program Uses Numbers 10 and 5 Input (10,5) Process (10 + 5 = 15) Output (15).
7
UFCFY5-30-1Multimedia Studio Variables and Types Need to declare variables to store data for the program Variables need to be of a particular data type program language data types can take many forms but the common ones are: integer (23, 345, 5, 0, -34) decimal (19.21, 0.001, 3.142, -0.64, 185.0) string (hello world, The Graduate, 007, 365 Days in a Year).
8
UFCFY5-30-1Multimedia Studio Java Data Types Java includes the following data types: int (for storing integer values) float (for storing decimal values) String (for storing string values).
9
UFCFY5-30-1Multimedia Studio Declaring Integer Variables in Java int firstNumber ; // stores first number variable name data type comment semi-colon statement ending double forward slash before single line comment
10
UFCFY5-30-1Multimedia Studio Decimal Type Declaration in Java float adecimalNumber; variable name type semi-colon statement ending
11
UFCFY5-30-1Multimedia Studio String Type Declaration in Java String aString; variable name type semi-colon statement ending
12
UFCFY5-30-1Multimedia Studio Declaring Variables in Java int firstNumber; // variable to store first number int secondNumber; //variable to store second number int addition; // variable to store the result of // adding the two numbers.
13
UFCFY5-30-1Multimedia Studio Assigning Values to Variables The process of storing a value into a variable is called assignment firstNumber = 10 variable assignment operator value
14
UFCFY5-30-1Multimedia Studio Assigning Values to Variables firstNumber = 10 ; // assigns 10 to first number secondNumber = 5; // assigns 5 to second number // add the numbers and store in addition variable addition = firstNumber + secondNumber ; The addition variable now holds the integer value 15
15
UFCFY5-30-1Multimedia Studio Declare & Assign Number Types float aDecimalNumber; // declare decimal variable aDecimalNumber = 5.34; // assign value
16
UFCFY5-30-1Multimedia Studio Declare & Assign String Types String myName; // declare string variable myName = “Barry Dean”; // assign value
17
UFCFY5-30-1Multimedia Studio A ‘Word’ on Comments // this is a single line comment /* this is a multi-line comment */
18
UFCFY5-30-1Multimedia Studio A Java Program public class HelloWorld { public static void main (String [] args){ System.out.println("Hello World"); }
19
UFCFY5-30-1Multimedia Studio A Java Program public class AddTwoNumbers { public static void main (String [] args){ int firstNumber = 5; int secondNUmber = 10; int total; total = 5 + 10; System.out.println(total); }
20
UFCFY5-30-1Multimedia Studio Viewing Output of Data The simple form of program output is via the Console Window To output text or variable values you use System.out.println() with the output data included in the brackets: System.out.println(“Hello World”); // simple text output To output more than one data item you include each item in double quotes and use the + operator: System.out.println(“The sum of 10 and 5 is “ + addition); System.out.printl (myName + “ wrote this program.”);
21
UFCFY5-30-1Multimedia Studio Coding Examples & Tasks Follow the instructions in the worksheet provided to try out the example programs. Carry out the associated coding exercises.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.