Professional Documents
Culture Documents
Itcs 113 MT S2 2021 - 2022 Fa
Itcs 113 MT S2 2021 - 2022 Fa
University of Bahrain
College of Information Technology
Department of Computer Science
Second Semester, 2021-2022
ITCS 113
A
Computer Programming I
Midterm Test
Date: 18th April 2022 Duration: 1 Hours and 15 Minutes
STUDENT NAME
STUDENT ID # SECTION #
1 10
2 20
3 20
TOTAL 50
Page 1 of 6
Question 1 (10 Points) – Form A - Please choose only one answer
3. What is the output for the following java code? int x=8;
switch(x%3) {
a. AA case 1: case 2:
b. AABB System.out.print("AA");
c. BB case 0: case 5:
d. CC System.out.print("BB"); break;
default:
System.out.print("CC");
}
a. AAA20 int k;
b. AAAA20 for(k=10; k<=20;k+=5)
c. AAAA25 System.out.print("A");
d. AAA25 System.out.print(k);
Page 2 of 6
Question 2 (20 Points)
ABC company plans to give social and year-end bonuses to its employees based on their marriage status and current
salary according to the following tables :
Salary Year-End Bonus
Marriage Status Social Bonus BD 2000 or above 20% of salary is given as a bonus
Married BD 200 Below 2000 A fixed bonus of BD 300
Single BD 100
Write Java program for calculating and displaying the total amount for an employee given his/her social status (in
any letter case) and salary as inputs. Assume all inputs are valid.
SAMPLE INPUT/OUTPUT
Enter social status (married or single) and salary: Married 2150.75
Total amount to be paid is BD 2780.9
Page 3 of 6
Page 4 of 6
Question 3 (20 Points)
Write a Java program that asks the user to input a list of blood types followed by the number of donors of each type
until the user input STOP in any letter case to terminate the input. Your program should find and display the
following:
Assume all inputs are valid and there is no duplicates in blood types.
Sample Input/Output
Enter blood type and number of donors (stop to terminate)
A- 7
AB+ 5
O- 19
B- 13
A+ 17
AB- 2
O+ 11
Stop
O- has the highest number of donors = 19
Number of blood types entered is 7
Page 5 of 6
Continue your answer on the next page
Page 6 of 6