



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
The instructions and questions for a bachelor's exam in information technology at cork institute of technology, focusing on software development. The exam includes questions on tax calculation, extending a bankaccount class, reading data from a file, and creating a simple calculator applet or frame. The document also covers topics such as object-oriented programming, inheritance, and overloading.
Typology: Exams
1 / 6
This page cannot be seen from the preview
Don't miss anything!




Instructions Answer FOUR questions. All questions carry equal marks.
Examiners: Mrs. G. MacSweeney Mr. E.A. Parslow Mr. P. O Connor Dr. D. Chambers Q1. Write an applet which prompts a user to enter his / her name and their annual salary. The program should calculate and display their tax for the year. Tax is calculated as follows:
salary <= €5000 tax = €0.
€5000 =< salary <= € 9000 tax = 20% of (salary - €5000)
salary >= €9000 tax = €800 + 40% of (salary - €9000)
( 25 Marks )
Consider the following simplified BankAccount class:
class BankAccount { public BankAccount() { } private double balance = 0;
System.out.println(balance); } public void deposit(double amount) { balance = balance + amount; } public void withdraw(double amount) { balance = balance - amount; } }
What change needs to be made to extend this class.
Write a SavingsAccount class by extending BankAccount which includes two new methods:
calculateInterest() which calculates the interest on the current balance addInterest() which adds the interest to the balance.
Add whatever other data items you think are necessary to write these methods
Override the withdraw() method to prevent the balance going into the red i.e. the balance should never be less than 0.0.
Write a short program to demonstrate how the SavingsAccount() class may be used.
Suggest how you could prevent the BankAccount class from being instantiated
Suggest another possible extension of the BankAccount class. Suggest some method prototypes it might have. ( 25 Marks )
(b) Using this class, write a program which reads a list of twenty people (i.e. twenty surnames, twenty forenames and twenty ages) from a text file (“people.txt”) and stores them in an array. The start of the program is as follows:
import java.io.*; public class MyArray { public static void main( String args[] ) throws IOException {
File f = new File("people.txt"); FileInputStream fs = new FileInputStream(f); InputStreamReader isr; BufferedReader fileInput; isr = new InputStreamReader(fs); fileInput = new BufferedReader(isr); (c) Change the program to search for and display the youngest person in the file.
( 25 Marks )
Write an applet or a frame which displays the canvas for a simple calculator as follows:
In your answer, include appropriate layout managers and panels. You do not need to include the ActionListener interface. ( 25 marks )
A library consists of books and borrowers. An efficient library system must take account of the
details each borrower and each book. Some of the information that is recorded includes the title of
the book the author, the name of the person borrowing the book, etc.
a) Write a (^) Book class that records (^) author and (^) title and can return (^) author and title. ( 6 marks )
b) Write a Borrower class which records name and idNumber and can return name and idNumber. ( 6 marks )
c) Write a LibraryTransaction class which contains the method lendBookDetails() – this displays details of both the borrowed book and the borrower. ( 6 marks )
d) A borrower Mary Adams (idNumber - A00001 ) borrows the book Ivanhoe by Walter Scott. Write a short program which uses the lendBookDetails() method to display this information. ( 7 marks )