You are on page 1of 2

UNIVERSITY EXAMINATIONS: 2019/2020

EXAMINATION FOR THE DEGREE OF BACHELOR OF SCIENCE IN


INFORMATION TECHNOLOGY/ BACHELOR OF BUSINESS IN
INFORMATION TECHNOLOGY
BIT 2204A /BBIT 310: JAVA PROGRAMMING

DISTANCE LEARNING

DATE: MAY, 2020 TIME: 6 HOURS

INSTRUCTIONS: Answer ALL Questions

SECTION B:
QUESTION ONE (20 MARKS)

(a) Write a java class that implements the following pseudocode [4 Marks]

1 Start
2. Read number N,
3. Set remainder as N modulus 2,
4. If remainder is equal to 0 then number N is even, else number N is odd
5. Print output.
6. Stop

(b) Write a java class that implements the following ATM pseudocode [5 Marks]

1
(c) Write a program called CircleComputation, which prompts user for a radius (of double) and
compute the area and perimeter of a circle. The output shall look like: [6 Marks]
Enter the radius: 1.2
The area is 4.5239
The perimeter is 7.5

(d) Write a program that performs the following tasks [5 Marks]


1. Declare variables for storing Marks
2. Prompts the user to enter total KCSE Marks.
3. Utilize switch structure to determine the grade (e.g. A,B ...)
4. Prints the grade

SECTION C:

QUESTION TWO (20 MARKS)

(a) Briefly explain the following java code [4 Marks]

public class PROG


{ public static void main(String[] args)
{ Int x,y,results,diff;
x = 9;
y = 4;
sum = x + y;
diff = x – y;
System.out.println(“sum is " + results);
System.out.println(“diff is " + diff);
}}

(b) Write a well commented java program that prints the following output. [4 Marks]

Age is: 30
Name is: job
Course is: Information Technology
Faculty is: FOCIM

(c) Write a java program for computing area of a triangle. The program should contain the following
features [4 Marks]

i. objects
ii. More than one methods

(d) Create class named student_names that prompts the user to enter three names of three students,
puts them in an Array, utilize do – while loop to read the names in the array and prints all the
of them [4 Marks]

(e) Write while-loop structure using a well commented java programming code that can print the
following five numbers [4 Marks]
1,2,3,4,5

You might also like