Home
Programming in Delphi and Java
Contents
1. Display the number of models in the models table SELECT couontrange as Number of cars from models Change the Air_bags field for the Nissan 4x4 double cab ModellD 18 to True UPDATE models SET air bags true WHERE modellD 18 DELETE records from the rental table WHERE the car registration is VBN307KZN DELETE from rentals WHERE carregistration VBN307KZN Display the number of cars in each group listed in the groups table according to the rentals table SELECT model name sum date until date_from as Total days from models rentals where models modellD rentals modellD group by model name Insert a new car into the Models table ModellD __ Model Name__ A C __ ABS brakes Tank Seats GroupID__ 25 Opel Corsa Yes No 45 4 Economy INSERT into models modellD model name a c abs_brakes tank seats groupID values 25 Opel Corsa yes no 45 4 4 Economy 21 mindset leam toza
2. and display a suitable message l P O Input x y z If x x y y Z z Display right angled or y y x X z Z triangle or 2 Z x x y y then else Display not right angled triangle Read a cell phone number Determine if it starts with a 0 and is 10 characters long to determine if it is a valid cell number and display a suitable message l P O Input cell If cell 1 0 and Display valid format length cell 10 then else Display not valid format 2 Implement the IPO tables in the previous question a Radius strtoint inputbox Input Enter the radius 5 Area pi radius radius Lbloutput caption floattostr area x strtoint inputbox Input Enter the length of side 1 5 y strtoint inputbox Input Enter the length of side 2 3 z strtoint inputbox Input Enter the length of side 3 4 If x x y y Z z or y y Xx X Z Z or z Z x x y y then Lbloutput caption right angled triangle else Lbloutput caption not right angled triangle else cell strtoint inputbox Input Enter cell number no spaces 0823456789 If cell 1 0 and length cell 10 then Lbloutput caption valid format else Lbloutput caption not valid format LESSON 6 WORKSHEET ANSWERS What is the purpose of the program planned in the flowchart Loop until the user inpu
3. outcome C lt 20 amp amp D lt 20 TRUE Outcome NOT C lt D Outcome C lt D_ FALSE Outcome C gt 20 or D lt 20 outcome C gt 20 OR D lt 20 TRUE Outcome C gt 20 OR D lt 300 AND outcome C gt 20 OR D lt 30 amp amp C lt D TRUE NOT C gt D Free your brain TASK ANSWERS 1 Use nested if statements to write a program to display the output Distinction if the mark is greater or equal to 80 and less than or equal to 100 Pass if the mark is between 40 and 79 inclusive Fail if the mark is between 0 and 39 inclusive and Invalid if the mark is gt 100 or lt 0 Use 77 as input for the mark DELPHI JAVA Var int mark 77 Mark integer if mark gt 100 OR mark lt 0 begin system out printIn Invalid mark 77 else if mark gt 80 if mark gt 100 OR mark lt 0 then Ibloutput caption Invalid else if mark gt 80 and lt 100 then Ibloutput caption Distinction else if mark gt 40 and lt 100 then Ibloutput caption Pass else Ibloutput caption Fail system out printIn Distinction else if mark gt 40 system out printin Pass else system out println Fail Note note how you logically exclude values every time you enter the next nested loop 2 Use a case statement or switch to display the season when the number of the month is entered Spri
4. fulfils its role correctly This is called information hiding Global variables are accessible to all members in the class can be used in all event handlers Local variables are declared in methods or code blocks and their scope is limited to that method Method parameters can only be accessed in the method body 1 Consider the code provided keeping the scope of variable in mind Predict the output TASK ANSWERS Output X 5 the local value of x Z 2 the global value of z Zx 20 used to multiply LESSON 9 WORKSHEET ANSWERS local x 5 passed to parameter z and in function the global value of x 4 is Name 3 methods to manipulate a string A method on the string type is called to manipulate the string It can be used to find the length of a string It can be used to count the number of times a given word or character appears in a string It can be used to convert lowercase into uppercase It can be used to reverse the order of characters e g abcd to dcba Complete the code to DELPHI JAVA Convert the string called sentence to New String new uppercase and assign it to variable new uppercase sentence sentence toUpperCase Convert the string called sentence to New String new lowercase and assign it to variable new lowercase sentence sentence toLowerCase Copy the first threee characters fromm the New String New string sentence and assign it to variable new copy sentence 1 3 sentence
5. many and morphism means form For example the same function or function name is used but the behaviour will be different Name the two types of polymorphism Method overloading static polymorphism early binding and method overriding dynamic polymorphism late binding Explain inheritance with an example Object oriented programming allows classes to inherit commonly used state and behavior from other classes For example Food in our previous example can now become the superclass of meat and fruit TASK ANSWERS 1 Give one example of where polymorphism can be used Possible answer Superclass animal with a move method and subclasses bird and dog where move will mean completely different things Superclass shape where a area method is declared and subclasses Circle Rectangle where the meaning of area is completedly different 2 Fill in the missing words You don t have to write code in parent you actually just know you will need a method but the child class will determine exactly what the content of the method will be Put only the signature in parent not specific but every child class MUST have a method with exactly the same signature where the method is specified 16 mindset leam loza Information Technology Grade 12 Answers Programming in Delphi and Java Free your brain LESSON 16 WORKSHEET ANSWERS Why is it necessary to close files at the end of a procedure CloseFile frees
6. random 100 1 do repeat System out printin Please input an integer guess strtoint inputbox Input Enter your answer 50 until guess secretnum Int x x sc nextint while x randomNumber 3 To keep increasing a value by 10 if it is smaller than 50 DELPHI JAVA Var float x x real while x lt 50 begin x x 1 1 x 5 J while x lt 50 do x t X 1 1 LESSON 5 WORKSHEET ANSWERS INPUT PROCESSING OUTPUT STORAGE How can the answer be calculated What basic operators What is the data type of the input What kind of data Where must the data be stored Do have to print What is the data type of the output How is the answer to does the input are needed be displayed or display the data represent What is the formula Do have to print or or store in need display the data or permanently Do need a loop store in Do need if permanently statements Do need to format the output TASK ANSWERS 1 Complete IPO tables for the following a Read the radius of a circle Then determine and display the area of the circle P O Input radius Area pi radius radius Display area n mindset p leam Information Technology Grade 12 Answers Programming in Delphi and Java Free your brain Read the length of three sides of a triangle Determine if it is a right angled triangle
7. substring 0 3 Assign the length of the string sentence to Len length sentence Int len len sentence length Assign the 4 character in the string New sentence 4 Char new sentence to new sentence charAt 3 Assign the position of the first space in Place pos sentence Int place sentence to place sentence indexOf n mindset p leam Information Technology Grade 12 Answers Programming in Delphi and Java Free your brain TASK ANSWERS 1 Create a flowchart for the program to remove the spaces in a sentence Input sentence Remove the space Is there a space in the sentence LESSON 10 WORKSHEET ANSWERS Write down the declaration for a constants array called arrSuits to display the four suits in a deck of cards JAVA String arrSuits Hearts Spades Clubs Diamonds DELPHI arrSuits array 0 3 of string Hearts Spades Clubs Diamonds What will be assigned to the variable called output in the following cases DELPHI JAVA Output arrsuits 0 Output arrSuits 0 Hearts Output Output Diamonds arrSuits 1 2 arrSuits 1 2 Output Output SpadesClubs arrSuits 1 arrsuits 2 arrSuits 1 arrsuits 2 TASK ANSWERS 1 Write a loop to populate an array of length 10 with random integers between 20 and 30 10 mindset leam toz
8. the memory space that was previously reserved for the file It also sends any data in the file buffer to the file on disk and updates the file s directory details on disk and it usually counts 1 mark Text files are used sequentially What does this mean Have to read through all the lines to get toa specific line like video tape Is it better to use While loop or a repeat Until Do while loop to read through the file Motivate WHILE take into account the unlikely possibility that the file exists but does not contain any data TASK ANSWERS 3 M6atch the columns with the basic keywords for data access to text files Function that links the file variable in RAM to the txt file gia on disk Opens an existing file for reading It puts the file pointer at F Reset tf the beginning of the file Creates and opens a new file If existing file with the same G Rewrite tf name existed the new one will overwrite the old Opens an existing text file for adding on at the end It puts Append tf the file pointer at the end of the file Reads a line from the file into variable line and then move E Readin tf line the file pointer to the beginning of next line text file moves file pointer to the next line Function that returns true if the file exists and false if it Fileexists abc txt does not exist Writes a line and then writes an end of line marker to the Hana Function that returns true if yo
9. 0 1 Food create c random 101 random 101 ran counter dom 101 random 101 arrFood counter new _ Food letter ff pp cc ee 15 mindset leam loza Information Technology Grade 12 Answers Programming in Delphi and Java Free your brain TASK ANSWERS 1 Write the code to search through the array of objects to find the food with the name entered by the user DELPHI JAVA Var i integer int i 0 Found boolean boolean found false Searchfood char System out printin Begin System out print Enter a food l 0 char searchFood Found false inKb readLine toUpperCase Searchfood inputbox Input Enter the while found false amp amp i lt 25 letter for the foodtype C 1 i While found false and I lt 25 do if arrFood i Begin getType toUpperCase equals searchFoo Inc i d If arrFood i gettype searchfood then found true Found true End If found If found then showmessage arrFood i getkj System out printIn arrFood i getKJ 2 else Else Showmessgae Not found System out println not found End LESSON 15 WORKSHEET ANSWERS Explain polymorphism with an example Polymorphism means the ability to take more than one form This is something similar to a word having several different meanings depending on the context It is the important concept of OOP from the Greek concept poly means
10. Information Technology Grade 12 Answers Programming in Delphi and Java LESSON 1 WORKSHEET ANSWERS Free your brain To write a program to provide information about trees in the botanical garden you need to declare some variables Choose the most appropriate data type for the variables Then choose variable names for these variables declare the variables and assign the value Acacia xanthophloea to the name 245 to the number of trees 21 87 to the Average height and NO or false to the Evergreen variable Description Data Declaration Declaration Assign the Assign the type in Delphi in JAVA value in value in JAVA Delphi Name of the String Treename String Treename treeName tree string treeName Acacia Acacia xanthophloea xanthophloea Number of Integer Number Int number Number 245 Number 245 this type of integer tree in the garden Average Floating AvgHeight Float AvgHeight avgHeight height for this point real avgHeight 21 87 21 87 type of tree in data meters type real Evergreen or Boolean Evergreen Boolean Evergreen evergreen not boolean evergreen false false Note Name is a reserved word in Delphi and should not be used as a variable name What is the biggest value that can be assigned to a variable of the type byte 255 What happens if you assign a bigger value to the variable than what the data type allows You
11. S 1 Study the class diagram below representing a client Client Fields Methods fID String constructor Create member ID name fName String fDateOfBirth String fAmount double getID String getName String getAmount double setAmount newAmount a Identify a constructor in the class diagram above constructor Create nember ID name b Identify a mutator in the class diagram above setAmount newAmount c Identify an accessor in the class diagram above getID String getAmount double d Identify a parameter in the example new amount 2 Code the accessor method getID DELPHI JAVA Function getlD string Public String getID Begin Return flD Return fID End 3 Code the mutator setAmount DELPHI JAVA Procedure Public void setAmount double setAmount newAmount double newAmount Begin fAmount newAmount fAmount newAmount End n mindset p leam Information Technology Grade 12 Answers Programming in Delphi and Java LESSON 8 WORKSHEET ANSWERS Complete the sentences Free your brain Modularity is a programming method in which the source code for an object can be written and maintained independently of the source code for other objects Modularity allows one object to send data to another object or ask the object to invoke a method The detail of what goes on inside the module is not important to the system as a whole as long as the module
12. That object is an array of arrays of ints Here the notation int 4 5 indicates that there are 4 arrays of ints in the array A and that there are 5 ints in each of those arrays Complete the code to populate a 2D array with random integers between 1 and 10 DELPHI JAVA For col 0 to 3 do for int col 0 col lt 4 col For row 0 to 4 do for int row 0 row lt 3 row 4 Arr col row random 10 1 arr col row Math round Math random 10 1 13 mindset leam toza Information Technology Grade 12 Answers Programming in Delphi and Java Free your brain TASK ANSWERS 1 Write the code to print a 2D array int arr new int 4 5 in rectangular form DELPHI JAVA Sum 0 for int row 0 row lt arr length row For row 0 to 4 do for int col 0 rcol lt arr row length row Begin System out print arr col row For col 0 to 3 do Line line inttostr Arr row col System out printin Redout lines add line End LESSON 13 WORKSHEET ANSWERS Define a class A class is a blueprint for an object_The class groups together values that logically belong together in a structure like a new data type A class is made up of fields private variables that contain data values and methods procedures and functions The class is not a variable you need to declare an object to use Define an object An object crea
13. a Information Technology Grade 12 Answers Programming in Delphi and Java Free your brain DELPHI JAVA Var arr array 0 9 of integer int arr J new int 10 k integer Begin for int i 0 i lt 10 i Randomize arr iJ Math round Math random 10 For k 0 to 9 do 20 Arr k random 11 20 2 Display the integers DELPHI JAVA Var arr array 0 9 of integer k integer Begin System out printIn Random numbers are For k 0 to 9 do for int i 0 i lt random length i Redoutput lines add inttostr Arr k System out printIn random i 3 Complete the empty boxes in the flowchart that is supposed to search through an array of 100 names The search must stop as soon as you find a match or when you reach the end of the array Input lookFor the string to look for Increase counter by 1 ounter maximum number of elements lookFor array counter 11 mindset leam Coza Information Technology Grade 12 Answers Programming in Delphi and Java Free your brain LESSON 11 WORKSHEET ANSWERS Complete the sentences a Bubble sort works by swapping two adjacent elements if they are not in order The process repeats until no more swapping is necessary b Insertion sort finds elements that are out of order and puts these elements in the right position c Selection sort finds the largest smallest element in the array and puts it in the corr
14. activate an eventhandler when a button is clicked OnClick To change the color of the form when you move the mouse over the panel OnMouseMove To capture the letter that you enter on the keyboard to make an object move on the form FormKeyPress To be able to use the arrow keys to make an object move on the form FormKeyUp 2 Complete the code to make an image move on the form when the arrow keys are Pressed DELPHI JAVA procedure TForm1 FormKeyUp Sender TObject var Key Word Shift TShiftState public void keyPressed KeyEvent ke begin if key vk_left then img1 Left img1 Left 10 if key vk_right then img1 Left img1 Left 10 switch ke getKeyCode if key vk_up then img1 top img1 top 10 if key vk_down then img1 top img1 top 10 end case KeyEvent VK_RIGHT xX X 10 case KeyEvent VK_LEFT 19 mindset leam Coza Information Technology Grade 12 Answers Programming in Delphi and Java Free your brain x XxX 10 case KeyEvent VK_DOWN y y 10 case KeyEvent VK_UP y y 10 this repaint LESSON 20 WORKSHEET ANSWERS Write down what the following acronyms stand for SQL Structured Query Language ODBC Open Database connectivity JDBC Java Database connectivity ADO ActiveX data components TASK ANSWERS Given the table in ACCESS see worksheet Complete SQL statements for the following queries i Dis
15. ect position It then repeats the process with the remaining part of te array until all elements are in the right order Explain why you need a temporary variable when you swap two values in an array Otherwise you will overwrite one of the values and in effect duplicate one value TASK ANSWERS 1 Declare an array of integer with 4 rows and 5 columns An array with 4 arrays of 5 integer DELPHI JAVA Var arr array 0 3 0 4 of integer int J arr new int 4 5 2 Write the code to calculate the sum of all the numbers in the 2D array declared in 1 DELPHI JAVA Sum 0 Sum all elements For col 0 to 4 do Int Sum 0 For row 0 to 3 do for int col 0 col lt arr length col Sum sum Arr row col for int row 0 row lt arr col length row Showmessage Sum inttostr sum sum sum arr col row System out print SUM sum 3 Complete the code to delete all items in column 3 of the array set the values to 0 DELPHI JAVA For row 0 to 3 do for int row 0 row lt arr col length row Arr row 3 0 arr 3 row 0 4 Use a method to sort the elements in the array arr that has n integer elements DELPHI JAVA Procedure bubble_sort var arr Tarr n Public static void bubble_sort int arr int n integer Int I j keep 0 for i 0 I lt n i for j 0 j lt n 1 j if arr i lt arr j keep arr i arr i arr
16. essor method getType to make the type of food available in the main class DELPHI JAVA function getKJ string Public String getKJ begin result ftype Return type end 5 Write an public accessor lowFat to return the boolean value true if the is less than 10 DELPHI JAVA function lowfat boolean Public boolean lowFat begin result fFat lt 10 Return fat lt 10 end LESSON 14 WORKSHEET ANSWERS Can you use arrays as data types for the fields that define the attributes Yes What will happen if you declare the procedures and functions in the private section Won t be able to use them in any other class application Assume the following class has been created see information provided in worksheet Declare an array named arrFood that can hold 25 objects of the class Food DELPHI JAVA Var arrFood array 1 25 of Food Food LlarrFood new Food 25 Create and dynamically populate the array of objects with random values between 0 and 100 for all the integer parameters and the names of the food A B y DELPHI JAVA Var c char char letter Counter integer int counter 0 Begin for letter A letter lt Y letter Counter 0 int ff int Math random 100 1 For c A to Y do int pp int Math random 100 1 Begin int cc int Math random 100 1 arrFood counter int ee int Math random 10
17. get overflow and might get negative values that are incorrect TASK ANSWERS 1 Find the errors in the following code DELPHI Corrected JAVA Corrected Var Var Public static void Public static void x y integer x y integer main string args main string args z integer z real int x int x begin begin x 5 xX 5 x 15 x BD int y int y y 6 y i 6 y 6 y 6 Z X Z X Y int z x y float z lbloutput caption lbloutput caption system out println z Z x y Z floattostr z system out println z end end Note in Delphi you have to convert the answer z to string to be able to display it The function floattostr converts real numbers to string and inttostr converts integer to string LESSON 2 WORKSHEET ANSWERS Fill in the appropriate relational operators for the expressions to be true Expression Answers 8 10 lt or lt gt or Joe Jack lt or lt gt or A a lt or lt gt or Note Letters and strings are ordered according to their ASCII values 1 mindset leam C0 2a Information Technology Grade 12 Answers Programming in Delphi and Java What is the order of precedence when using boolean and relational operators NOT AND OR followed by the relational operators Determine the value of outcome in the following cases if C 10 and D 20 DELPHI JAVA Outcome C lt 20 and D lt 20
18. inding the largest value of two values that were entered and display equal if they are the same Input x Input y If x gt y then display x Else if y gt x then display y Else x y 3 To swap two values using an extra data container LESSON 4 WORKSHEET ANSWERS Name 3 types of loops For while repeat do while Name the three parts of a for loop or the three thing the for statement does Initialise test boolean expression and Change update the loop variable Name the most appropriate loop Description Loop type To display Welcome 10 times For To guess a number between 1 and 100 until you get it right Repeat Do while while To search though a list until you find a value or reach the end of While the list To keep increasing a value by 10 if it is smaller than 50 Repeat Do while while a in Information Technology Grade 12 Answers Programming in Delphi and Java TASK ANSWERS Complete the code for the following programs 1 To display Welcome 10 times Free your brain DELPHI JAVA For I 1 to 10 do Redout lines add welcome Int For i 1 i lt 1 1 i system out printIn welcome 2 To guess a number between 1 and 100 until you get it right DELPHI JAVA Var int randomNumber Secretnum guess integer int Math random 100 1 begin Scanner sc new Scanner System in secretnum
19. ion as per requirements 3 Invalid data set check application behaviour for negative values alphanumeric string inputs and generate and display error messages 4 Illegal data format System should not accept data in invalid or illegal format generate error messages 5 Boundary extreme data very large or very small 6 Large amounts of data TASK ANSWERS 1 How do you use the debugger in your software program to step through your program one line at a time Press F7 repeatedly or use the icon 2 How do you set watches in the software program Ctrl F5 or use the menu 3 How do you add breakpoints in the software program Use the menu Run Add breakpoint or click in the left hand side margin 4 List a couple of bugs that you have encountered in programs while stepping through the code Loops or selection code does not have brackets or begin and end statements in the correct places Incorrect conditions in loops Variables redeclared or out of scope LESSON 18 WORKSHEET ANSWERS List 4 design principles when creating a graphical user interface 1 Provide visual appeal 2 Clarity The interface and lanquage used should be easy to understand 3 Consistency Similar components should have a similar look position and use 4 Efficiency Minimize eye and hand movements or other meaningful answers How do you make the interface aesthetically pleasing Provide meaningful contrast between screen elements Create groupings Align scree
20. j arr j keep 12 mindset leam toza Information Technology Grade 12 Answers Programming in Delphi and Java Free your brain LESSON 12 WORKSHEET ANSWERS Comment on the types of loops that are used to populate and display 2D arrays Use two For Loops nested one inside the other when creating a 2D array The outer For Loop rows inner For Loop columns List 5 examples where 2D arrays could be used in programs An array variable can be used to store many data items of the same kind under the same name Each item is distinguished from the other by means of an index Examples 1 A program to book seats for a movie 2 A program that can do the times table and display it in a string grid 3 Useful to store objects for programming sketches that involve some sort of grid or matrix 4 A program that lets a user enter some values at the beginning of each day such as the number of appointments 5 A program that contains to check if specific items or seats or similar are available for example to allow people to book the seat they want on a bus or at a music festival Explain what is meant by the following declaration DELPHI JAVA Var arr array 0 3 0 4 of integer int J arr new int 4 5 DELPHI It declares a 2D array of integers with 4 columns and 5 rows JAVA It declares a variable arr of type int and it initializes that variable to refer to a newly created object
21. n elements and groups Provide three dimensional representation Use colours and graphics effectively and simply Identify the components on the following G Name N Choose teacher v D Registered Summary B Check box Name B Surname Grade Registered E C8 Grade Teacher A Edit C Radio group g er D Combobox e C e btn1 F E Richedit F Button TASK ANSWERS Consider the following user interface and use the design principles to comment on the design 18 mindset leam toza Information Technology Grade 12 Answers Programming in Delphi and Java Free your brain gt Click on the elephant if you can eS Layout not visually appealing no alignment overlap too small and too many components Lack of Clarity Some components not labelled Inconsistency Click button should be bottom right if it is the last thing to do In efficiency Have to type all subjects could have selected with check boxes or other meaningful answers LESSON 19 WORKSHEET ANSWERS Name a few events that can be used On Click for buttons Double cllick Menu item is selected Mouse events onMousemove OnCreate onCLose OnActivate for windows OnKeypressed OnKeyUp OnkeyDown Name 4 types of event listeners Action listener MouseListener MouseMotionListener WindowListener TASK ANSWERS 1 Match the columns Choose the appropriate events To
22. ng 9 10 11 Summer 12 1 2 Autumn 3 4 5 Winter 6 7 8 Use an integer value month with value 3 in your answer an D Information Technology Grade 12 Answers Programming in Delphi and Java Free your brain DELPHI JAVA Var int month 3 month integer switch month begin case 9 case 10 case 11 month 3 System out printIn Spring case month of 9 11 Ibloutput caption Spring 12 1 2 Ibloutput caption Summer 3 5 Ibloutput caption Autumn 6 8 Winter Else Ibloutput caption Invalid End End break case 12 case 1 case 2 System out printIn Summer break case 3 case 4 case 5 System out printIn Autumn break case 6 case 7 case 8 System out printin Winter break default System out printin Invalid month break Note that you can use sub ranges in DELPHI but you have to list all cases in JAVA LESSON 3 WORKSHEET ANSWERS Match the columns Which symbols are used in flowcharts to indicate the following INPUT and C A OUTPUT DECISIONS A B T PROCESSING B C YO A What is the purpose of the arrows in flowcharts To indicate the flow of the program TASK ANSWERS 1 Use a sequential flowchart to calculate the area of a rectangle iD Information Technology Grade 12 Answers Programming in Delphi and Java aeons 2 Use pseudocode to plan the solution of f
23. play the Model Name and fuel tank size fields from the models table with column headings Car and Fuel tank SELECT Model Name as Car tank as Fuel tank from models ii Display all fields of models where the tank field is blank empty SELECT FROM models where tank is null iii Display all the fields from the models table WHERE the modelname starts with A to H SELECT FROM models where model name between A and I iv Display all the fields from the models table WHERE the model description is longer than 10 characters SELECT FROM models where len model name gt 10 v Display all fuel tank capacities only once SELECT Distinct tank FROM models vi Display Model names starting with an H SELECT model name FROM models where model name like H vii Write a query where the user can input the number of seats and then all models with that number of seats are displayed SELECT model name from models where seats Seats where seats is a variable and the user entered the value viii Display the model names sorted in descending order by seats and then ascending order by fuel tank capacity SELECT model name FROM models ORDER BY seats desc tank ix Display the maximum range of all cars in the models table SELECT max range as Maximum from models Q 20 mindset D toza Information Technology Grade 12 Answers Programming in Delphi and Java xi xii xiii xiv Free your brain
24. st 0 for int count 0 count lt 8 count 5 System out printin Enter next integer value sc nextInt 6 if value lt smallest smallest value 7 System out printf Lowest value is d value A ON Line Value Count Value lt Smallest smallest 2 7 F 3 7 F 0 4 7 0 F 0 5 9 F 0 F F Set smallest to the first value entered instead of 0 otherwise it will only change when you enter negative values LESSON 7 WORKSHEET ANSWERS Give one word for the following n mindset p leam Information Technology Grade 12 Answers Programming in Delphi and Java Information hiding so that other classes have to use accessors and mutators to see or modify information in the class A method to make private variables in a class available A method used to modify private variables in a class Members that can be accessed anywhere where the class can be referenced Members that are invisible outside of the program or unit where its class is declared Special method to initialise a new instance of a class A Value received by a method of a class to change the viaue of a field of a class A data type indicating the data format to be returned by a method Free your brain Encapsulation Accessor Mutator Public member Private member Constructor Parameter Return type TASK ANSWER
25. ted from a class is called an instance of the class One object is a bundle of variables and related functions and procedures True or false Many objects can be created using the same class True Many objects can be created from the same class just like many variables can be declared of the same data type TASK ANSWERS 1 Define aclass Tfood The type of food is of the type string other information also provided DELPHI JAVA Food class Tobject Public class Food Private fType string Private string type fFat fProtein fCarbo fEnergy integer Private int fat Private int protein Private int carbo Private int energy 2 Write a public constructor method which accepts values for all five private fields through the parameters to initialise the private fields DELPHI JAVA constructor create t f p c e integer Public Food String t int f int p int c int e begin ftype t Type t fFat f Fat f fProtein p Protein p fCarbo C carbo C fEnergy energy end 14 mindset leam loza Information Technology Grade 12 Answers Programming in Delphi and Java Free your brain 3 Write an public accessor method getKJ to make the number of kilojoules available in the main class DELPHI JAVA function getKJ integer Public int getKJ begin result fenergy Return energy end 4 Write an public acc
26. ts a value between 8 and 12 What does UML stand for Unified Modelling Language TASK ANSWERS 1 Identify possible actors communication and use cases in the following scenario A client brings a pet to the vet The Vet examines the pet and prescribes medicine or performs a procedure if necessary The client pays n an D Information Technology Grade 12 Answers Programming in Delphi and Java Free your brain ACTORS USE CASE client Makes appointment Buys food medicine etc Pays account owns pet Vet Diagnose Prescribes Performs procedure Invoice client Pet Owned by client 2 The following program is supposed to input 10 values in a loop and find the smallest value entered The output is incorrect Use a trace table to show how the values of all variables in the program change as each line of code is executed and find the mistake Explain what to do to debug the program DELPHI JAVA 1 Var smallest value count integer Scanner sc new Begin Scanner System in 2 Value 1 Int value strtoint inputbox Input Enter an System out printin Enter an integer integer 0 3 Smallest 0 4 For count 0 to 8 do Begin 5 Value strtoint inputbox Input Enter next integer 0 6 If value lt smallest then smallest value End 7 Lbloutput caption inttostr smallest int value sc nextInt int smalle
27. u have reached the end of C Eof tf the file and false if there are more lines of text or end of line markers to read from the file LESSON 17 WORKSHEET ANSWERS Name three types of errors that can occur in programming and give an example of each Compiler errors including syntax errors e g when you do not declare a variable spell incorrectly do not convert to the correct data type Runtime errors try to open a file that does not exist input letters when integer input is expected Logical errors your program runs but do not deliver the expected output Which type of error can be prevented when you use exception handlers Runtime errors Describe what you understand as good documentation in programming Documentation is the written text that accompanies computer software It either explains how it operates or how to use it You should comment in your programming code to explain the purpose of each method and provide a user manual for the end users of your program Technical details like object design and database design should be available for other programmes who want to improve or build on your code 17 mindset p leam C0 2a Information Technology Grade 12 Answers Programming in Delphi and Java Free your brain Describe the types of data to include in your test cases Test that your program will work correctly with 1 No data Generate and display error messages 2 Valid data Program should funct
Download Pdf Manuals
Related Search
Related Contents
Casio SL-1100TV Owner's Manual Catálogo Power Coil 2014 Chapter 4 - AutomationDirect TERMITE & CARPENTER ANT PDFはこちらをご覧下さい。 宝具精出ガス浄化装置の取り扱いについて Copyright © All rights reserved.
Failed to retrieve file