GRADE 11 NOVEMBER 2014 INFORMATION TECHNOLOGY P1€¦ · GRADE 11 NOVEMBER 2014 INFORMATION...

23
NATIONAL SENIOR CERTIFICATE GRADE 11 NOVEMBER 2014 INFORMATION TECHNOLOGY P1 MARKS: 150 TIME: 3 hours This question paper consists of 11 pages. *IINFTDM1*

Transcript of GRADE 11 NOVEMBER 2014 INFORMATION TECHNOLOGY P1€¦ · GRADE 11 NOVEMBER 2014 INFORMATION...

NATIONAL SENIOR CERTIFICATE

GRADE 11

NOVEMBER 2014

INFORMATION TECHNOLOGY P1

MARKS: 150 TIME: 3 hours

This question paper consists of 11 pages.

*IINFTDM1*

2 INFORMATION TECHNOLOGY P1 (NOVEMBER 2014) INSTRUCTIONS AND INFORMATION 1. This is a three-hour examination. Because of the nature of this examination, it

is important to note that you will not be permitted to leave the examination room before the end of the examination session.

2. You require the files listed below in order to answer the questions. They are

either on a CD issued to you, or the invigilator/educator will tell you where to find them on the hard drive of the workstation you are using or in a network folder.

P1 Data folder P1Q1 Folder P1Q2 Folder P1Q3 Folder P1Q4 Folder

Q1_p.dpr Q1_p.dfm Q1_p.pas

Q2_p.dpr Q2_u.pas Q2_p.dfm furniture.txt

Q3_p.dpr Q3_u.pas Q3_p.dfm

Q4_p.dpr DMQ4.dfm DMQ4.pas Q4_u.pas Q4_p.dfm electric.mdb

3. If a CD containing the above files was issued to you, write your name and

surname on the label of the CD.

4. Save your work at regular intervals as a precaution against power failures. 5. Rename the P1 Data folder as your Name and Surname. 6. Type in your name and surname as a comment in the first line of each

program.

7. Read ALL the questions carefully. Do only what is required. 8. At the end of this examination session you will be required to hand in the CD

with all the files with the work you have done or you must make sure that ALL the files with your work have been saved on the network as explained to you by the invigilator/educator.

9. Ensure that ALL files can be read. 10. During the examination you may use the HELP functions of the software. You

may NOT make use of any other resource material.

(NOVEMBER 2014) INFORMATION TECHNOLOGY P1 3

QUESTION 1: DELPHI PROGRAMMING Customers always want to open accounts with you. In order to verify their credit worthiness you have to call head office in Johannesburg. To speed up the process you decide to design a small program to determine whether a customer is eligible, or not eligible, for credit. Open the program and answer the following questions:

1.1 Display the title, name and surname of the customer in one line when the

Check Eligibility button is clicked. (3) 1.2 Calculate tax: 1.2.1 Design a function called NetSalary which receives the gross salary

as a parameter and then returns the net salary after income tax has been deducted. Make use of the table below to calculate the amount of tax to be paid. TAKE NOTE: The first R 67 134 per year is non-taxable.

Taxable Income/Year Tax Rate R0 – R 165 600 18% R165 601 – R258 750 25% R258 751 – R358 110 30% R358 110 – R500 940 35% R500 941 – R638 600 38% R638 601 and above 40%

Example of calculation: Salary per month is R15 500.00 Annual Salary = R15 500*12 = R186 000.00 Taxable Amount = (R186 000.00 – R67 134.00) = 118 866.00 Annual Tax = 118 866*0.18 = R21 395.88 Monthly Tax = R21 395.88/12 = R1 782.99 Net Salary = R15 500.00 – R1 782.99 = R13 717.01 (15)

SCENARIO: You have just been appointed manager of Grandpa Furniture Shop in East London.

4 INFORMATION TECHNOLOGY P1 (NOVEMBER 2014) 1.2.2 Call the function and display the Net Salary. (2) 1.3 Calculate the Net Family Salary by adding the spouse’s net salary to the

customer’s net salary. Make use of an appropriate method (Netsalary function). (3)

1.4 After subtracting all the expenses from the net salary, it should display the

income available. (3) 1.5 After repaying the loan a customer should be left with a minimum of

R3 000 if they are to be approved; otherwise the customer does not qualify for the loan. Calculate the monthly repayment and whether the customer qualifies for the loan. Display your answers.

(8) x Enter your name and surname as a comment line in the first line of the

file named Q1_u.pas. x Save the program. x Make a printout of the code of the Q1_u.pas file. [34]

(NOVEMBER 2014) INFORMATION TECHNOLOGY P1 5 QUESTION 2: DELPHI PROGRAMMING You are asked to examine the contents of a text file named furniture.txt saved in the folder named P1Q2. This file contains the data referring to the description of items in stock and a code number for each type of item. Each field is delimited with a comma. The content of the text file is shown below.

Emma 3-piece Black,BSEBP70 Grace 4-piece Sleigh - Cherry,BSSSS9

Rimini 2-door Budget Robe,BURBR19 The first entry example represents:

A furniture item with a description and a special code of BSEBP70 The BS means that it’s a Bedroom Suite

The BU means that it’s a Bedroom Unit 2.1 Declare TWO arrays with class scope, named arrDesc and arrCodes,

which can store a maximum of 35 elements. The code numbers will be stored in arrCodes and the descriptions will be stored in arrDesc. (2)

2.2 Write a Boolean function called Valid which will receive a string (sCode)

containing the furniture code and a character (cDesc) containing the first letter of the description. In order for the code to be valid, the following rules apply: x The code must be 7 characters long. x The first five characters must be uppercase alphabetical characters. x The next two characters must be numerical digits. x The third character of the code must be the same as the first

character of the description. (14) 2.3 Reading, checking and displaying: 2.3.1 Write a procedure loadfile which must read information from the

text file furniture.txt. This procedure must open the text file and initialise a loop to read the data. Each line represents a record of a type of furniture in the shop. Add code to this procedure to test if the text file furniture.txt exists. If the file does not exist, a suitable error message must be displayed and the program must terminate. Add further code to the procedure to initialise the file and to read each line of text from the text file. The descriptions need to be stored in arrDesc and the codes need to be stored in arrCodes.

6 INFORMATION TECHNOLOGY P1 (NOVEMBER 2014) 2.3.2 Read and Check Button:

The loadfile method must be called and all codes need to be validated. The description code for each furniture item must be displayed in the richedit component. If the code is valid then 'Valid Code’ must be added; if the code is invalid then 'Invalid Code' must be added. The total number of valid and invalid codes must also be displayed. Example of output below:

(31) 2.4 Categories Button: The first two characters of all the Code indicate the

category of the furniture, BU stands for Bedroom Unit and BS stands for Bedroom Suite. Write code to display a list of the furniture types and the number of items in each category and the total items in the list.

(11) x Enter your name and surname as a comment line in the first line of the

file named Q2_u.pas. x Save the program. x Make a printout of the code of the Q2_u.pas file.

[58]

(NOVEMBER 2014) INFORMATION TECHNOLOGY P1 7 QUESTION 3: DELPHI PROGRAMMING When you are creating an account for the client on your accounting system, a password has to be automatically generated from the Name, Surname and Day of Birth of the client (eg. 13 November 1997, so the input will be 13). The password is in the format vvnnnn where the first v is the first vowel found in the client's name and the second v is the first vowel in the client's Surname. The nnnn is a number generated from the client's date of birth (the day the client was born on). Add 2000 to the date of birth, then add a randomly generated number between 1 and 999 to get the number nnnn.

x Enter your name and surname as a comment line in the first line of the file named Q3_u.pas.

x Save the program. x Make a printout of the code of the Q3_u.pas file. [20]

8 INFORMATION TECHNOLOGY P1 (NOVEMBER 2014) QUESTION 4: DELPHI PROGRAMMING AND DATABASE The database, electric.mdb, in the P1Q4 folder supplied to you, contains details of electrical gadgets in stock at the furniture shop. The database contains a single table named Televisions. Data about the different types of televisions is stored in this table. Each record refers to a type of television, the price of one television and the number of televisions of this type in stock. The fields in this table are defined as follows: Field Type Description Example ID Autonumber AutoID 2 Price Number The price of one television in Rands 4560.99 Brand Text The brand of television Sony Size Number The screen size 32 TypeT Text The type of television screen LCD Stock Number Number of Televisions in stock 3

The following is an example of the data contained in the table:

The folder P1Q4 also contains an incomplete Delphi project – Q4_p.dpr – which contains two units, namely a data module named DMQ4.pas and Q4_u.pas (the main unit). The data module, DataForm, contains the following components: ADOConnection, ADOTable and a DataSource.

(NOVEMBER 2014) INFORMATION TECHNOLOGY P1 9 The program should be able to connect to the database named electric.mdb. When you do QUESTION 4.1 and you find that the connectivity is not in place, use the following steps to establish connection with the database: x Click on the ADOConnection component in the Data Module. x Click on the Ellipse button (three dots) to the right of the ‘ConnectionString’

property in the Object Inspector. x Click on the Build button which takes you to the Data Link Properties dialogue

box. x Select Microsoft Jet 4.0 OLE DB Provider and click on Next. x The first option on the Connection tabsheet allows you to browse and find the

electric.mdb file. x Remove the user name Admin. x Click on the Test Connection button. Click OK on each one of the open

dialogue windows. NOTE: If you cannot establish connectivity with the database at all when you execute the program you must still do and submit the programming code for marking. 4.1 Btn A: Write code to display the data sorted in the following order:

The Brand field in descending order and the Size field in ascending order. Example of output (first few records):

(3)

10 INFORMATION TECHNOLOGY P1 (NOVEMBER 2014) 4.2 BtnB: Write code to count the number of LG televisions and display the

answer using a ShowMessage component.

(4) 4.3 BtnC: Write code to count the number of televisions in stock.

(7) 4.4 BtnD: Write code to calculate the total Rand value of that particular

television brand as entered by the user (use an inputbox component). If the brand entered is not found, display a suitable message. Example of output:

Or

(12)

(NOVEMBER 2014) INFORMATION TECHNOLOGY P1 11 4.5 BtnE: Enter code to input a new record with the following values:

Price = 1924.00 Brand = LG Size = 14 TypeT = Monitor Stock = 2 (7)

4.6 BtnF: Enter code to delete the record you have just entered in

QUESTION 4.5. (5) x Enter your name and surname as a comment line in the first line of the

file named Q4_u.pas. x Save the program. x Make a printout of the code of the Q4_u.pas file. [38]

TOTAL: 150

NATIONAL SENIOR CERTIFICATE

GRADE 11

NOVEMBER 2014

INFORMATION TECHNOLOGY P1 MEMORANDUM

MARKS: 150

This memorandum consists of 12 pages.

2 INFORMATION TECHNOLOGY P1 (NOVEMBER 2014)

QUESTION 1: DELPHI DATABASE CONNECTIVITY Mark Allocation SAMPLE DELPHI SOLUTION QUESTION 1 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Buttons, CheckLst, ComCtrls; type TForm1 = class(TForm) Label1: TLabel; Label2: TLabel; edtName: TEdit; edtSur: TEdit; Label3: TLabel; edtGross: TEdit; Label4: TLabel; edtSGross: TEdit; Label5: TLabel; edtMaid: TEdit; Label6: TLabel; edtFood: TEdit; Label7: TLabel; edtAcco: TEdit; Label8: TLabel; edtLoan: TEdit; Button1: TButton; BitBtn1: TBitBtn; Label10: TLabel; edtTitle: TEdit; redDisplay: TRichEdit; Button2: TButton; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; totCash:real; implementation //uses Unit2;

(NOVEMBER 2014) INFORMATION TECHNOLOGY P1 3

{$R *.dfm} // Function to calculate the Income Tax and Net Salary function NetSalary(msGross:string9):real9; var yGross, mrGross:real; begin mrGross:=StrToFloat(msGross); yGross:=mrGross*129 -67134.00; 9 if (yGross>0) and (yGross<165600.00) 9 then NetSalary:=mrGross - yGross*0.18/129 else if (yGross>165001.00) and (yGross<258750.00) 9 then NetSalary:=mrGross - mrGross*0.259 else if (yGross>258751.00) and (yGross<358110.00) 9 then NetSalary:=mrGross - mrGross*0.309 else if (yGross>358111.00) and (yGross<500940.00) 9 then NetSalary:=mrGross - mrGross*0.359 else if (yGross>500941.00) and (yGross<638600.00) 9 then NetSalary:=mrGross - mrGross*0.389 Else if (yGross>638601) then NetSalary:=mrGross - mrGross*0.40; 9 end; procedure TForm1.Button1Click(Sender: TObject); Var netSal,famSal, totSal,totExp,tloan:real; begin redDisplay.Clear; //Set the height of the form Form1.ClientHeight:=417; //Calculate the salaries netSal:=NetSalary(edtGross.Text); 9 famSal:=netSal9+ NetSalary(edtSGross.Text); 9 //Calculate the Total Expenses totExp:=strtofloat(edtMaid.Text) + strtofloat(edtAcco.Text)+ strtofloat(edtFood.Text); 99 //Calculate the money available for the loan repayment totCash:=famSal-totExp; 9 tLoan := strtofloat(edtLoan.text); 9 mval:=totCash-(tLoan/24); 99 //Display redDisplay.Lines.Add(edtTitle.Text9 +' '+edtName.Text9+' '+edtSur.Text9); redDisplay.Lines.Add('Your Monthly Net Salary after Tax deduction is '+ FloattoStr(netSal)); 9 redDisplay.Lines.Add('Your Familys Monthly Net Salary after Tax deduction is '+ FloattoStr(famSal)); 9 redDisplay.Lines.Add('After expenses your income is '+ FloattoStr(totCash)); 9 if mval >3000 then9 redDisplay.Lines.Add('Monthly Repayment of '+FloatToStr((tLoan/24))+'You Qualify for the Loan') 9 Else9 redDisplay.Lines.Add('Monthly Repayment of '+FloatToStr((tLoan/24))+' You do not qualify for the Loan'); 9 end;

4 INFORMATION TECHNOLOGY P1 (NOVEMBER 2014)

procedure TForm1.FormCreate(Sender: TObject); Begin //Clear all the edits edtName.Clear; edtSur.Clear; edtTitle.Clear; edtGross.Clear; edtSGross.Clear; edtMaid.Clear; edtFood.Clear; edtAcco.Clear; edtLoan.Clear; end; end. [34]

(NOVEMBER 2014) INFORMATION TECHNOLOGY P1 5

QUESTION 2: DELPHI PROGRAMMING

SAMPLE: DELPHI SOLUTION QUESTION 2 unit Q_2; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls; type TForm2 = class(TForm) redDisplay: TRichEdit; Button1: TButton; Categories: TButton; procedure FormCreate(Sender: TObject); procedure Button1Click(Sender: TObject); procedure CategoriesClick(Sender: TObject); private { Private declarations } function cdValid(sCode: String; nChar:String): Boolean; procedure loadfile; public { Public declarations } end; var Form2: TForm2; arrCodes:Array[1..35] of string; 9 arrDesc:Array[1..35] of string; 9 iNum:integer; 9 implementation {$R *.dfm} //----------------------------------------------------------------------- procedure TForm2.Button1Click(Sender: TObject); begin loadfile; 9 end; procedure TForm2.CategoriesClick(Sender: TObject); var iCount,sBU : Integer; sList , sCateg : String; begin loadfile; 9 redDisplay.Clear; sBU := 0; 9 redDisplay.Lines.Add('List of furniture type represented: '); 9 redDisplay.Lines.Add(' '); For iCount := 1 to iNum do9 Begin sCateg := Copy (arrFCodes[iCount], 1 ,2); 9 if sCateg='BU' then9 begin sBU:=sBU+1; 9 end;

6 INFORMATION TECHNOLOGY P1 (NOVEMBER 2014)

End; redDisplay.lines.add('The number of Bedroom Units is : ' +IntToStr(sBU)); 9 redDisplay.lines.add('The number of Bedroom Suites is : ' +IntToStr(iNum-sBU9)); 9 redDisplay.lines.add('The Total number is : ' +IntToStr(iNum)); 9 end; function TForm2.cdValid(sCode: String9; cdesc:char9): Boolean; 9 var k : Integer; begin result := True; 9 if sCode[3] <> cdesc 9then result:=false9 else begin if length(sCode) <> 79 then Result := false9 else begin for k := 1 to 5 do9 if not(sCode[k] in ['A'..'Z']) 9 then Result := false; 9 for k := 6 to 7 do9 if not(sCode[k] in ['0'..'9']) 9 then Result := false; 9 end; end; //end else end; //----------------------------------------------------------------------- procedure TForm2.loadfile; 9 var TextF :TextFile; 9 sName, sLine,sCode : String; iCommaPos, iInvalid : Integer; begin if FileExists('furniture.txt') = False then9 begin MessageDlg('Sorry data file not located - application will now terminate ', mtError,mbOk] , 0); 9 Application.Terminate; 9 end; iNum := 0; 9 iInvalid := 0; 9 AssignFile(TextF, 'furniture.txt'); 9 Reset(TextF); 9 while not eof(TextF) do9 begin inc(iNum); 9 Readln(TextF, sLine); 9 iCommaPos := Pos (',' , sLine); sName := Copy (sLine , 1 , iCommaPos - 1); 99 Delete(SLine,1,iCommaPos); sCode:=sLine; 99 arrCodes[iNum] 9:= sCode; arrDesc[iNum] 9:=sName; if CdValid(sCode,sName[1]) 9 //test for valid then begin redDisplay.Lines.Add(arrDesc[iNum] 9+' '+arrCodes[iNum] 9+ '<----Valid Code' ); 9

(NOVEMBER 2014) INFORMATION TECHNOLOGY P1 7

end else9 begin inc(iInvalid); 9 redDisplay.Lines.Add(arrFDesc[iNum]+' '+arrFCodes[iNum]+ ' <--- Invalid Code' ); 99 end; //end if end; redDisplay.Lines.Add('' ); redDisplay.Lines.Add('Number of invalid Codes: ' + IntToStr(iInvalid)); 9 redDisplay.Lines.Add('Number of valid Codes: ' + IntToStr(iNum-iInvalid)); 9 CloseFile(TextF); 9 end; procedure TForm2.FormCreate(Sender: TObject); begin redDisplay.Clear; end; end. [58]

8 INFORMATION TECHNOLOGY P1 (NOVEMBER 2014)

QUESTION 3: DELPHI PROGRAMMING Mark Allocation SAMPLE DELPHI SOLUTION QUESTION 3 unit Q3_u; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) edtName: TEdit; edtSurname: TEdit; edtDob: TEdit; lblName: TLabel; lblSurname: TLabel; lblDob: TLabel; btngenerate: TButton; lblPassword: TLabel; procedure btngenerateClick(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.btngenerateClick(Sender: TObject); Var cName, cSurname,v1,v2:string; cDob,k,i:integer; begin cName:= edtName.Text; 9 cSurname:=edtSurname.Text; 9 {if cName='' then ShowMessage('Enter Name Please'); if cSurname='' then ShowMessage('Enter Surname Please'); if edtDob.Text ='' then ShowMessage('Enter Date of Birth Please'); Exit;}

(NOVEMBER 2014) INFORMATION TECHNOLOGY P1 9

cDob:=StrToInt(edtDob.Text); 9 v1:=''; v2:=''; for i := 1 to length(cName) 9do if cName[i] In ['a','e','i','o','u','A','E','I','O','U'] 99 then v1:=v1+cName[i]; 99 for i := 1 to length(cSurname) 9 do cSurname[i] In ['a','e','i','o','u','A','E','I','O','U'] 99 then v2:=v2+cSurname[i]; 99 Randomize; 9 k:=cDob9+20009+random(99)+1; 9 lblPassword.Caption:= v1[1] 9+v2[1] 9 + IntTostr(k) 9; end;

[20]

10 INFORMATION TECHNOLOGY P1 (NOVEMBER 2014)

QUESTION 4: DELPHI PROGRAMMING AND DATABASE Mark Allocation SAMPLE DELPHI SOLUTION QUESTION 4 unit Q_4; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Grids, DBGrids,DMQ4, StdCtrls, Buttons; type TForm2 = class(TForm) DBGrid1: TDBGrid; BtnA: TButton; BtnB: TButton; BtnC: TButton; BtnD: TButton; BtnE: TButton; BtnF: TButton; BitBtn1: TBitBtn; procedure BtnAClick(Sender: TObject); procedure BtnBClick(Sender: TObject); procedure BtnCClick(Sender: TObject); procedure BtnDClick(Sender: TObject); procedure BtnEClick(Sender: TObject); procedure BtnFClick(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form2: TForm2; implementation {$R *.dfm} procedure TForm2.BtnAClick(Sender: TObject); begin DataForm.AdoTable1.Sort9 := 'Brand DESC9, Size ASC9'; end; procedure TForm2.BtnBClick(Sender: TObject); begin with DataForm.AdoTable19 do begin Filter := 'Brand = ''LG'''; 9 Filtered := True;

(NOVEMBER 2014) INFORMATION TECHNOLOGY P1 11

end; ShowMessage('Types of Televisions by LG: 9 ' + IntToStr(DataForm.AdoTable1.RecordCount9)); DataForm.AdoTable1.Filtered := False; end; procedure TForm2.BtnCClick(Sender: TObject); var iSum : Integer; begin iSum := 0; 9 with DataForm do begin AdoTable1.Open; 9 AdoTable1.First; 9 while not AdoTable1.Eof do9 begin iSum := iSum + AdoTable1['Stock']; 9 AdoTable1.Next; 9 end; end; ShowMessage('Number of all Televisions in Stock: ' + IntToStr(iSum)); 9 end; procedure TForm2.BtnDClick(Sender: TObject); var Tbrand:string; cost:real; begin cost:=0; 9 Tbrand:=inputbox('Search','Enter Brand',''); 9 with DataForm do begin AdoTable1.Open; 9 AdoTable1.First; 9 while not Adotable1.Eof do9 begin if AdoTable1['Brand']=Tbrand then9 cost:=cost + (AdoTable1['Price']* adoTable1['Stock']); 9 AdoTable1.Next; 9 end; end;//while if cost =0 then9 ShowMessage('That type of Television does not exist: Check you spelling and try again' ) 9 else9 ShowMessage('Total Value of Televisions : R' FloatToStr(cost));9 DataForm.AdoTable1.Filtered := False; end; procedure TForm2.BtnEClick(Sender: TObject); begin with DataForm do begin

12 INFORMATION TECHNOLOGY P1 (NOVEMBER 2014)

AdoTable1.Insert; 9 AdoTable1['Price']:=1924.00; 9 AdoTable1['Brand']:='LG'; 9 AdoTable1['Size']:=14; 9 AdoTable1['TypeT']:='Monitor'; 9 AdoTable1['Stock']:=2; 9 AdoTable1.Post; 9 end; end; procedure TForm2.BtnFClick(Sender: TObject); var NPost:integer; begin with DataForm do begin AdoTable1.First; 9 AdoTable1.Next; while Not AdoTable1.Eof do9 begin if (AdoTable1['Brand']='LG') 9 And (AdoTable1['Size']=14) then AdoTable1.Delete9 else AdoTable1.Next; 9 end; end; end; end. [38]

TOTAL: 150