5th Form Sample Question(Programming SBA Guide) 2015

Embed Size (px)

DESCRIPTION

Programming Example

Citation preview

  • Page 1 of 14

    5th Form Sample Question (Guide SBA)There was a proud Country by the name of WOLMERS which consisted of six (6) states namely: BARROWS, COWPER, FORBES,MURRAY, HOLLAR and HOWSON. Annually each state conducts a SPORTS DAY within each state. Yearly the state representativemust provide a budget forecasting and showing actual financial information relating to the event which is send to the Chief Event

    Coordinator of the country. Develop an algorithm that will accept and store the name, the total actual expenditure and total projectedexpenditure for each state.. No more than # states should be accepted. The algorithm should also determine if the status for each state is a

    surplus, deficit, or breakeven. Additional algorithm should determine the number of states with a deficit, and finally produce a report from

    the data collected.

    Do the following for the question above: PSEUDOCODE SOLUTION TRACE TABLE PASCAL SOLUTION

    o Source codeo Compilationo Input Screeno Output Screen

    PSEUDOCODE SOLUTIONSTART

    DECLARE count AS INTEGERDECLARE deficit AS INTEGER

    DECLARE state AS STRING ARRAY OF SIZE 6DECLARE expenseP AS REAL ARRAY OF SIZE 6DECLARE expenseA AS REAL ARRAY OF SIZE 6DECLARE balance AS REAL ARRAY OF SIZE 6DECLARE status AS STRING ARRAY OF SIZE 6

    FOR count = 1 TO 6 DOPRINT Enter the name of the StateREAD state[count]

    PRINT Enter the Projected ExpenseREAD expenseP[count]

    PRINT Enter the Actual Expense

  • Page 2 of 14

    READ expenseA[count]

    ENDFOR

    FOR count = 1 TO 6 DO

    balance[count] expenseP[count] expenseA[count]

    ENDFOR

    FOR count = 1 TO 6 DO

    IF ( balance[count] > 0) THENstatus[count] SURPLUS

    ENDIF

    IF ( balance[count] < 0) THENstatus[count] DEFICIT

    ENDIF

    IF ( balance[count] = 0) THENstatus[count] BREAK-EVEN

    ENDIFENDFOR

    deficit 0FOR count = 1 TO 6 DO

    IF(status[count] = DEFICIT) THENdeficit deficit + 1

    ENDIF

    ENDFOR

    PRINT FINANCIAL INFORMATION REPORT ON EACH STATE OF WOLMERSPRINT STATE NAME ACTUAL EXPENSE PROJECTED EXPENSE STATUSFOR count = 1 TO 6 DO

    PRINT state[count], , expenseA[count], ,expensesP[count], , status[count]ENDFORPRINT THE NUMBER OF STATES THAT HAVE A DEFICIT STATUS IS:, deficit

    STOP

  • Page 3 of 14

    SAMPLE INPUT OR DATA# STATE PROJECTED EXPENSE ACTUAL

    EXPENSE1 Cowper $15,000.00 $10,000,002 Forbes $11,000.00 $14,000.003 Howson $20,000.00 $20,000.004 Murray $9,000.00 $10,000.005 Hollar $15,000.00 $9,000.006 Barrows $10,000.00 $10,000.00

  • Page 4 of 14

    TRACETABLE (PG 1)Deficit 0 0 0 0 0 0Count 1 2 3 4 5 6

    State 1 Cowper Cowper Cowper Cowper Cowper Cowper2 Forbes Forbes Forbes Forbes Forbes3 Howson Howson Howson Howson4 Murray Murray Murray5 Hollars Hollars6 Barrows

    expenseP 1 15000 15000 15000 15000 15000 150002 11000 11000 11000 11000 110003 20000 20000 20000 200004 9000 9000 90005 15000 150006 10000

    expenseA 1 10000 10000 10000 10000 10000 100002 14000 14000 14000 14000 140003 20000 20000 20000 200004 10000 10000 100005 9000 90006 10000

    Balance 123456

    Status 123456

    Output

  • Page 5 of 14

    TRACETABLE (PG 2)Deficit 0 0 0 0 0 0Count 1 2 3 4 5 6

    State 1 Cowper Cowper Cowper Cowper Cowper Cowper2 Forbes Forbes Forbes Forbes Forbes Forbes3 Howson Howson Howson Howson Howson Howson4 Murray Murray Murray Murray Murray Murray5 Hollars Hollars Hollars Hollars Hollars Hollars6 Barrows Barrows Barrows Barrows Barrows Barrows

    expenseP 1 15000 15000 15000 15000 15000 150002 11000 11000 11000 11000 11000 110003 20000 20000 20000 20000 20000 200004 9000 9000 9000 9000 9000 90005 15000 15000 15000 15000 15000 150006 10000 10000 10000 10000 10000 10000

    expenseA 1 10000 10000 10000 10000 10000 100002 14000 14000 14000 14000 14000 140003 20000 20000 20000 20000 20000 200004 10000 10000 10000 10000 10000 100005 9000 9000 9000 9000 9000 90006 10000 10000 10000 10000 10000 10000

    Balance 1 5000 5000 5000 5000 5000 50002 -3000 -3000 -3000 -3000 -30003 0 0 0 04 -1000 -1000 -10005 6000 60006 0

    Status 123456

    Output

  • Page 6 of 14

    TRACETABLE (PG 3)Deficit 0 0 0 0 0 0Count 1 2 3 4 5 6

    State 1 Cowper Cowper Cowper Cowper Cowper Cowper2 Forbes Forbes Forbes Forbes Forbes Forbes3 Howson Howson Howson Howson Howson Howson4 Murray Murray Murray Murray Murray Murray5 Hollars Hollars Hollars Hollars Hollars Hollars6 Barrows Barrows Barrows Barrows Barrows Barrows

    expenseP 1 15000 15000 15000 15000 15000 150002 11000 11000 11000 11000 11000 110003 20000 20000 20000 20000 20000 200004 9000 9000 9000 9000 9000 90005 15000 15000 15000 15000 15000 150006 10000 10000 10000 10000 10000 10000

    expenseA 1 10000 10000 10000 10000 10000 100002 14000 14000 14000 14000 14000 140003 20000 20000 20000 20000 20000 200004 10000 10000 10000 10000 10000 100005 9000 9000 9000 9000 9000 90006 10000 10000 10000 10000 10000 10000

    Balance 1 5000 5000 5000 5000 5000 50002 -3000 -3000 -3000 -3000 -3000 -30003 0 0 0 0 0 04 -1000 -1000 -1000 -1000 -1000 -10005 6000 6000 6000 6000 6000 60006 0 0 0 0 0 0

    Status 1 SURPLUS SURPLUS SURPLUS SURPLUS SURPLUS SURPLUS2 DEFICIT DEFICIT DEFICIT DEFICIT DEFICIT3 BREAK-EVEN BREAK-EVEN BREAK-EVEN BREAK-EVEN4 DEFICIT DEFICIT DEFICIT5 SURPLUS SURPLUS6 BREAK-EVEN

    Output

  • Page 7 of 14

    TRACETABLE (PG 4)Deficit 0 1 1 2 2 2Count 1 2 3 4 5 6

    State 1 Cowper Cowper Cowper Cowper Cowper Cowper2 Forbes Forbes Forbes Forbes Forbes Forbes3 Howson Howson Howson Howson Howson Howson4 Murray Murray Murray Murray Murray Murray5 Hollars Hollars Hollars Hollars Hollars Hollars6 Barrows Barrows Barrows Barrows Barrows Barrows

    ExpenseP 1 15000 15000 15000 15000 15000 150002 11000 11000 11000 11000 11000 110003 20000 20000 20000 20000 20000 200004 9000 9000 9000 9000 9000 90005 15000 15000 15000 15000 15000 150006 10000 10000 10000 10000 10000 10000

    ExpenseA 1 10000 10000 10000 10000 10000 100002 14000 14000 14000 14000 14000 140003 20000 20000 20000 20000 20000 200004 10000 10000 10000 10000 10000 100005 9000 9000 9000 9000 9000 90006 10000 10000 10000 10000 10000 10000

    Balance 1 5000 5000 5000 5000 5000 50002 -3000 -3000 -3000 -3000 -3000 -30003 0 0 0 0 0 04 -1000 -1000 -1000 -1000 -1000 -10005 6000 6000 6000 6000 6000 60006 0 0 0 0 0 0

    Status 1 SURPLUS SURPLUS SURPLUS SURPLUS SURPLUS SURPLUS2 DEFICIT DEFICIT DEFICIT DEFICIT DEFICIT DEFICIT3 BREAK-EVEN BREAK-EVEN BREAK-EVEN BREAK-EVEN BREAK-EVEN BREAK-EVEN4 DEFICIT DEFICIT DEFICIT DEFICIT DEFICIT DEFICIT5 SURPLUS SURPLUS SURPLUS SURPLUS SURPLUS SURPLUS6 BREAK-EVEN BREAK-EVEN BREAK-EVEN BREAK-EVEN BREAK-EVEN BREAK-EVEN

    Output

  • Page 8 of 14

    TRACETABLE (PG 5)Deficit 0 0 0 0 0 0Count 1 2 3 4 5 6

    State 1 Cowper Cowper Cowper Cowper Cowper Cowper2 Forbes Forbes Forbes Forbes Forbes Forbes3 Howson Howson Howson Howson Howson Howson4 Murray Murray Murray Murray Murray Murray5 Hollars Hollars Hollars Hollars Hollars Hollars6 Barrows Barrows Barrows Barrows Barrows Barrows

    ExpenseP 1 15000 15000 15000 15000 15000 150002 11000 11000 11000 11000 11000 110003 20000 20000 20000 20000 20000 200004 9000 9000 9000 9000 9000 90005 15000 15000 15000 15000 15000 150006 10000 10000 10000 10000 10000 10000

    ExpenseA 1 10000 10000 10000 10000 10000 100002 14000 14000 14000 14000 14000 140003 20000 20000 20000 20000 20000 200004 10000 10000 10000 10000 10000 100005 9000 9000 9000 9000 9000 90006 10000 10000 10000 10000 10000 10000

    Balance 1 5000 5000 5000 5000 5000 50002 -3000 -3000 -3000 -3000 -3000 -30003 0 0 0 0 0 04 -1000 -1000 -1000 -1000 -1000 -10005 6000 6000 6000 6000 6000 60006 0 0 0 0 0 0

    Status 1 SURPLUS SURPLUS SURPLUS SURPLUS SURPLUS SURPLUS2 DEFICIT DEFICIT DEFICIT DEFICIT DEFICIT DEFICIT3 BREAK-EVEN BREAK-EVEN BREAK-EVEN BREAK-EVEN BREAK-EVEN BREAK-EVEN4 DEFICIT DEFICIT DEFICIT DEFICIT DEFICIT DEFICIT5 SURPLUS SURPLUS SURPLUS SURPLUS SURPLUS SURPLUS6 BREAK-EVEN BREAK-EVEN BREAK-EVEN BREAK-EVEN BREAK-EVEN BREAK-EVEN

    Output FINANCIALINFORMATION

    REPORT ON EACHSTATE OF WOLMERS

    NAMEACTUAL EXPENSE

    PROJECTED EXPENSESTATUS

    Cowper, 15000,10000, DEFICIT

    FORBES,11000,14000,SURPLUS

    HOWSON,20000,20000,

    BREAK-EVEN

    MURRAY,9000,10000,SURPLUS

    HOLLAR,15000,9000,DEFICIT

    BARROWS,10000, 10000,BREAK-EVENTHE NUMBEROF STATES

    THAT HAVE ADEFICIT

    STATUS IS: 2

  • Page 9 of 14

    PASCAL SOLUTION or SOURCE CODE// Candidate Name: Jane Brown//Centre #: 100200//Territory: Jamaica//Candidate #: 1111// Subject: Information TechnologyPROGRAM StatesOfWolmers;USES wincrt, crt; // These are included to use the clear screen (i.e. clrscr ())VAR// Declaration of all the variables that will be used in this program

    count: INTEGER;deficit: INTEGER;state: ARRAY[1..6] of STRING;expenseP : ARRAY[1..6] of REAL;expenseA : ARRAY[1..6] of REAL;balance : ARRAY[1..6] of REAL;status : ARRAY[1..6] of STRING;

    BEGIN//This is where the main program startsFOR count := 1 TO 6 DO//This Loop we are populating the arraysBEGIN

    WRITELN();WRITELN('______________________________________');

    WRITELN();WRITE('ENTER THE NAME OF THE STATE: ');READLN(state[count]);

    WRITELN();WRITE('ENTER THE PROJECTED EXPENSE: ');READLN(expenseP[count]);

    WRITELN();WRITE('ENTER THE ACTUAL EXPENSE: ');READLN(expenseA[count]);

    WRITELN('______________________________________');WRITELN();

    END;READLN();

    FOR count := 1 TO 6 DO//This loop is calculating the balance by subtracting Actual from ProjectedBEGIN

    balance[count] := expenseP[count] - expenseA[count];

  • Page 10 of 14

    END;FOR count := 1 TO 6 DO//This loop is to determine if the state has a SURPLUS, DEFICIT or BREAK-EVENBEGIN

    IF balance[count] > 0 THENstatus[count] := 'SURPLUS';

    IF balance[count] < 0 THENstatus[count] := 'DEFICIT';

    IF balance[count] = 0 THENstatus[count] := 'BREAK-EVEN';

    END;deficit := 0;FOR count := 1 TO 6 DO// This loop is to count the number of states in DEFICITBEGIN

    IF status[count] = 'DEFICIT' THENdeficit := deficit + 1;

    END;CLRSCR();// This is to CLEAR the SCREENWRITELN('_________________________________________________________________________');WRITELN('_________________________________________________________________________');WRITELN(' A FINANCIAL REPORT ON THE STATES OF WOLMERS');WRITELN('_________________________________________________________________________');WRITELN('_________________________________________________________________________');WRITELN('STATE NAME PROJECTED EXPENSE ACTUAL EXPENSE STATUS');WRITELN('_________________________________________________________________________');FOR count := 1 TO 6 DO//This loop is outputting the content of the arraysBEGIN

    WRITELN(state[count],' ', expenseP[count]:5:2,' ',expenseA[count]:5:2,'',status[count]);

    WRITELN('-------------------------------------------------------------------------');END;WRITELN('THE NUMBER OF STATES THAT HAVE A DEFICIT STATUS IS: ',deficit);WRITELN('_________________________________________________________________________');

    READLN();END.//This is where the main program stops

  • Page 11 of 14

  • Page 14 of 14

    COMPILATIONEvidence that program compiled without errors

  • Page 15 of 14

    DATA INPUTINPUT DATA

  • OUTPUT SCREEN