La Trobe University, Bendigo

La Trobe University, Bendigo

<p>CSE1PE Programming Environment 2008 Practice Exam 1 Solution</p><p>Question 1</p><p>(a) i * j / 2</p><p>5 * 2 / 2 10 / 2 5</p><p>(b) x – 0.8 / j + (i * 2)</p><p>6.4 – 0.8 / 2 + (5 * 2) 6.4 – 0.8 / 2 + 10 6.4 – 0.4 + 10 6 + 10 16</p><p>Question 2</p><p>(a) i >= 5 And j <> 2</p><p>5 >= 5 And 2 <> 2 True And 2 <> 2 True And False False</p><p>(b) x < 0 Or Not x > 10</p><p>6.4 < 0 Or Not 6.4 > 10 False Or Not 6.4 > 10 False Or Not False False Or True True</p><p>Question 3</p><p>Values are – i: 5 x = 6.40 or</p><p>Values are - i: 5 x = 6.40</p><p>Question 4</p><p>(a) What are some major features of UNIX?</p><p> Multi-user  Command driven  Multiple user accounts  One directory tree  Reliability 2008 Practice Exam 1 Solution Programming Environment (CSE1PE)</p><p>(b) What is ftp used for? How would you connect to redgum using ftp? What different file transfer modes are available? Name an alternative ftp program available for Windows.</p><p> Transferring files  ftp ironbark.bendigo.latrobe.edu.au or ftp, then open ironbark.bendigo.latrobe.edu.au  ASCII, Binary  One of: ws_ftp, cuteftp etc</p><p>(c) What is the alias command used for? Give an example.  aliases can be used to define command shortcuts  aliases should be specified in .bashrc if they are to be generally available  e.g. alias l=”ls –al”</p><p>Question 5</p><p>(a) pwd (b) ls (c) ls –al or ls –a -l (d) mv test.java test2.java (e) nedit test2.java& (f) javac test2.java (g) java test2 (h) lpr –Pitlab5 test2.java (i) mkdir examples (j) cp test2.java examples/test3.java (k) cd examples (l) rm ../test2.class (m) cd or cd ~ (n) chmod o-w * (o) cat ../klray/a1.java (p) less /usr/staff/tim/q1.java or more </p><p>Question 6</p><p>(a) What is meant by input validation? Give two examples (code NOT required).</p><p> Checking a value input by a user is correct  Examples: checking a month number of between 1 and 12; Checking a membership of a club is Full, Junior or Life ("F", "J" or "L")</p><p>(b) What is a sentinel value? What is it used for?  A special value input by a user to indicate that the end of input.  The sentinel value should not be able to be confused with a normal valid value e.g -1 for a mark  Used to indicate the end of input in a while loop.</p><p>Page 2 2008 Practice Exam 1 Solution Programming Environment (CSE1PE)</p><p>Question 7</p><p>Line Member membership membership total Conditions Input/ Output Number ship Fee Name Type Fees 1, 2 0 3 J membership type ? J 4 "J" <> "X" ? is True 5, 12, 13 "J" = "F" ? is False 16, 17 "J" = "J" ? is True 18 80 19 "Junior" 23 - 25, 6 0 + 80 = 80 7 membership Name = Junior; membership Fee = 80 8 membership type ? X 9, 4 "X" <> "X" ? is False 10 Total Fees = 80 11</p><p>Question 8</p><p>Option Compare Database Option Explicit</p><p>Sub Main() Dim category As String Dim concession As String Dim price As Double Dim reason As String Dim totalTakings As Double</p><p> totalTakings = 0 concession = InputBox("Concession (Y=Yes, N=No, X=eXit) ?") While concession <> "X" If concession = "Y" Then reason = InputBox("Reason (C=Child, P=Pensioner) ?") If reason = "C" Then category = "Child" price = 8 Else category = "Pensioner" price = 9 End If Else category = "Full" price = 12 End If totalTakings = totalTakings + price Debug.Print category; ": $"; Format(price, "0.00") concession = InputBox("Concession (Y=Yes, N=No, X=eXit) ?") Wend Page 3 2008 Practice Exam 1 Solution Programming Environment (CSE1PE)</p><p>Debug.Print "Total takings = $"; Format(totalTakings, "0.00") End Sub</p><p>Page 4 2008 Practice Exam 1 Solution Programming Environment (CSE1PE)</p><p>Question 9</p><p>(a) Defining Diagram</p><p>Inputs Processing Outputs averageBalance Input averageBalance, numberOfTrans fees numberOfTrans Calculate fees interestRate Determine interestRate interest Calculate interest Display fees, interestRate, interest</p><p>(b) Pseudo Code</p><p>CalcFeesAndInterest() Input averageBalance WHILE averageBalance >= 0 DO Input numberOfTrans IF averageBalance < 1000 THEN fees = 40 + numberOfTrans * 0.50 interestRate = 0 ELSE IF numberOfTrans < 10 THEN fees = 40 ELSE fees = 40 + (numberOfTrans – 10) * 0.50 ENDIF interestRate = 3 ENDIF interest = averageBalance * interestRate / 100 Display fees, interestRate, interest Input averageBalance ENDWHILE STOP</p><p>(c) Data Dictionary</p><p>Identifier Name Data Type Description averageBalance Double The average balance in the account over the year in $. fees Double The fees payable on the account of the year in $. interest Double The interest earned on the account for the year in $. interestRate Double The interest rate applicable to the account in %. numberOfTrans Integer The number of transactions on the account fore the year.</p><p>Page 5</p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    5 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us