Cos 1511 May 2011 Memo
Cos 1511 May 2011 Memo
NB: Please make a tick for each mark – it is required by the new assessment
procedure, i.e. if the student obtains 7/10 for a question, there should be 7 √’s
These answers are guidelines. Please give marks for correct logic, even if
answered different to the solutions. If needed, write a note to the moderator of
how marks were given in this case.
Do not subtract marks for the same error twice in the same question. (especially
question 3)
SECTION A 20 marks
Question 1: 5
Question 2: 4
Question 3: 3
Question 4: 1 Each question 2 marks
Question 5: 3
Question 6: 2
Question 7: 2
Question 8: 1
Question 9: 2
Question 10: 2
SECTION B 70 marks
QUESTION 1 4 marks
QUESTION 2 6 marks
Note to markers: For questions 2(a) and (b) the mark is given for the highlighted field.
For questions 2(c) – (e), if the student left out the single and double quotes, but the value
is correct, please give the mark.
(a)
'n
line 20 "PROGRAMMING" "PROGRAMMING" "COS1512" 'n' ' 800
'n
line 21 "PROGRAMMING" "PROGRAMMING 2" "COS1512" 'n' ' 800
[2]
(b)
'y
line 28 "PROGRAMMING" "PROGRAMMING 2" "COS1512" 'n' ' 800
[1]
2 COS1511/COS111U memorandum May 2011
Note to markers: Student must use a nested if loop, as it is stated in the question.
Students may have put the cout statement within each if or else in which case
they will have 5 cout statements for the colour and one for the error message.
Make sure { } pairs have been used in this case. If no { } pairs have been used,
subtract 1 mark for incorrect logic. Only one mark for cout for fee and one
mark for error message cout.
if (number > 10 && number < 21) is also correct. Same for other
if’s
QUESTION 4: 8 MARKS
Give marks for any correct cout statement asking the user to guess a number.
The student could also have tested userCorrect inside the while loop instead
of testing it as one of the conditions – give marks if logic is correct.
(Many students answered this question without using userCorrect. We gave
marks for correct logic).
#include <iostream>
using namespace std;
int main()
{
int num1, num2;
int sum; //sum of num1 and num2;
int userGuess; // the number guessed by the user
const int MAXGUESSES = 5;//maximum number of guesses allowed
int noOfGuesses ; // the number of guesses by the user
bool userCorrect; //user has guessed correctly or not
3 COS1511/COS111U memorandum May 2011
noOfGuesses = 0;
userCorrect = false;
cout << "Enter two large integer values:" << endl;
cin >> num1 >> num2;
sum = num1 + num2;
if (!userCorrect)
{
cout<<"Sorry better luck next time!" <<endl;
cout<<"The sum was "<<sum;
}
return 0;
}
QUESTION 5: 12 MARKS
Note to markers: The first two parameters must be const variables – deduct ½ mark
for each one that does not have the const.
const string monthP[12] and const float rainfallP[12] is also
correct.
}
4 COS1511/COS111U memorandum May 2011
QUESTION 6 15 marks
14]
(a)
int inStaff[DEPARTMENT][STORE]; 2
(b)
QUESTION 7 6 marks
Note to markers: Do not deduct marks if “...” is not included in the cout statement
(a)
struct MenuItemType 1
{
string menuItem; 1
float menuPrice; 1
};
(b)
for ( int i = 0; i < 3; i++)
{
cout <<customerOrder[i].menuItem 1
<<" ... R "<<customerOrder[i].menuPrice<<endl; 1
amountDue = amountDue + customerOrder[i].menuPrice; 1
}
cout<<"Amount Due .....R " << amountDue <<endl;
5 COS1511/COS111U memorandum May 2011
QUESTION 8 6 marks