


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
These are the Old Exam of Software Development which includes Primenumber, Palindrome, Payrate, String Responsibility, Double Payrate, Double Time, String Name, Private Double Calculatepay, Public Void Displaydetails etc.Key important points are: Statistical Analysis, Namespace, Loanaccount, Annualinterestrate, Account Number, Loan Balance, Exclamation Mark, Semicolon, Employee Record, Credit Balance
Typology: Exams
1 / 4
This page cannot be seen from the preview
Don't miss anything!



Instructions: Examiner: Ms Gemma O’Callaghan Answer questions 1 and any two others. Mr. J. Greenslade Question 1 is compulsory. Mr. J. Walsh
Question 1: (50 marks) (a) What is the output from the following program? #include
int procedure(double &num1, int repetition);
int main() { double x, y; int z;
x = 6.0; z = 3;
cout<<" procedure: "<< procedure (x,z)<<endl; cout<<"x :"<<x<<endl; y = 7.0; cout<<" procedure again: "<< procedure (y,4)<<endl; cout<<"y: "<<y<<endl;
return 0; }
int procedure(double &num1, int repetition) { int count = 0; do { num1= num1+1.1;
repetition --; count++; }while(repetition > 0);
return count; } (6 marks)
(b) Create a class called LoanAccount. Use a static class variable to hold the annualInterestRate for all account holders. Each object of the class contains the following data members, an account number and a loan balance which indicates the total amount that is currently owed on the loan account. Provide a method calculateMonthlyInterest() which will calculate the monthly interest by multiplying the loan balance by the annualInterestRate divided by 12.Provide a constructor method that allows an object of this class to be initialised when it is declared. (10 marks)
(c) Write a statement to declare a file pointer called input. Write a statement to open the file “Assignment.txt” that is associated with the file pointer for reading. Write a statement to close the file pointer when you are finished with it. (6 marks)
(d) Write C++ code to read from the file “Assignment.txt” that you opened above and count the number of punctuation characters in the file. (e.g. full stop, comma, question mark, exclamation mark and semicolon)
(6 marks)
(e) Write the C++ code to display the following pattern.
**
(6 marks)
(f) Write a C++ function that takes an integer value and returns the number with its digits reversed. For example, given the number 5689, the function should return 9865. (6 marks)
(g) Write a structure template for an employee record consisting of their employee number, their first name, their surname, their department and their salary. Write statements to input values from the keyboard for each member of the employee record.
Question 4: (25 marks) (a) Explain the differences between arrays and linked lists. (4 marks)
(b) Show how to define the structures used to be able to create a linked list of characters. (5 marks)
(c) Write the C++ code needed to create a linked list of integers that is made up of three nodes. head -> 1 -> 2 -> 3 -> NULL (10 marks)
(d) Write a function to add an element to the front of a linked list of integers.