BIT 2204A BBIT 310 BSD 2107 BISF 2201 BAC 2201 – JAVA PROGRAMMING KCA Past Paper

UNIVERSITY EXAMINATIONS: 2019/2020
EXAMINATION FOR THE DEGREE OF BACHELOR OF SCIENCE IN
INFORMATION TECHNOLOGY/ BACHELOR OF BUSINESS IN
INFORMATION TECHNOLOGY AND BACHELOR OF SCIENCE IN
APPLIED COMPUTING
BIT 2204A /BBIT 310/ BSD 2107/ BISF 2201/ BAC 2201: JAVA
PROGRAMMING
FULL TIME/PART TIME/ DISTANCE LEARNING
DATE: MAY, 2020 TIME: 6 HOURS
INSTRUCTIONS: Answer ALL Questions

SECTION B: 20 MARKS DURATION: 3 HOURS
a) Write a program that will evaluate simple expressions such as 2 + 3 and 1.19 * 4.27. The
expressions are to be typed in by the user. The input should always consist of a number,
followed by an operator, followed by another number. The operators that are allowed are
+, -, *, and / for addition, subtraction, multiplication and division respectively. Your
program should read an expression, print its value, read another expression, print its
value, and so on. The program should end when the user enters 0 as the first number on
the line. A sample user/system interaction can be:
Enter expression:
3.4 * 5.6
The value is:
3.4 * 5.6 =19.04
10 Marks
b) An interior design company has approached you to develop an application that can help
them to calculate cost of carpeting a house. They are carpeting a house with three rooms.
Write a Java program to compute the cost of carpeting these rooms. Room objects have
dimensions of width and length, and they can compute and return their area and (given
the price per square unit) the cost to carpet themselves. The main method of the Room
class should create a room object and use a loop to process each of three rooms: get the
dimensions and carpet price, write out the individual areas and costs, add the three costs,
then write out the total cost.
5 Marks
Write a java program with each of the following methods:
a) Method celsius returns the Celsius equivalent of a Fahrenheit temperature, using the
calculation:
C=5.0/9.0*(F-32);
b) Method Fahrenheit returns the Fahrenheit equivalent of a Celsius temperature, using
the calculation: .
F=9.0/5.0*C+32
Write an applet program that uses these methods that enables the user to enter either a
Fahrenheit temperature and display the equivalent Celsius or enter a Celsius temperature
and display the equivalent Fahrenheit. Use TextField objects for input and outputs
5 Marks
SECTION C: 20 MARKS DURATION: 3 HOURS
a) In a given bank, there are two types of bank accounts, namely Saving and Current.
In both accounts, details of account number, holder name and balance must be kept.
Both account have operations to check balance and to deposit. The withdraw
operation is in both accounts but the conditions are different. In savings account, the
withdrawal is only possible if balance is more than the amount being withdrawn. For
current account, there is overdraft limit set for each client. Customers can withdraw
beyond their balance but cannot go beyond the overdraft. Only Savings accounts earn
interest on balance at a rate determined by the bank at the end of calendar year.
Required: Use a Java program to implement the solution to the scenario.
[20 Marks]

(Visited 211 times, 1 visits today)
Share this:

Written by