CC102 Fundamentals of Programming Midterm Exams First Term 2024 2025 Final Updated 2
CC102 Fundamentals of Programming Midterm Exams First Term 2024 2025 Final Updated 2
MIDTERM Examination
First Term, S.Y. 2024 – 2025
II. TRUE / FALSE. Write T on the space provided if the statement is correct;
otherwise, write F if the statement is incorrect.
____________ 1. The byte can hold whole number between -128 to 127.
____________ 2. Short is greater than integer and byte in terms of size.
____________ 3. Float is use in fractional number/s.
____________ 4. Boolean can hold either true or false only.
____________ 5. The symbol == means not Equal to.
____________ 6. The symbol >= means Less than or Equal to.
____________ 7. The symbol || means Or.
____________ 8. The use of “import java.util.Scanner;” is to import library into the program.
____________ 9. The “System.out.println();” keyword computes the input and output.
____________ 10. The “System.out.printf();” keyword formats the input or output.
III. MATCHING TYPE. Match the column A (flowchart names) into column B (flowchart
symbols). Write the correct answer on the space provided.
A B
_____ 1. Decision
A
_____ 5. Preparation
E
K.
IV. PROBLEM SOLVING. Solve the given problems and write the answer on the space
provided.
A. Write the missing code. Read and analyze the given codes below, then provide the
correct code in order to display the correct output.
import java.util.Scanner;
public (1.) _____________ Midterm_Exam
{
public (2.) _____________ void main (String [ ] args)
{
Scanner (3.) _____________ = new Scanner( (4.) _____________ );
String FN, LN, MN, CurrentCourse ;
int age ;
String gender, prog = "Program by: ", myName = "Eddiemar" ;
System.out.print("Course: ");
CurrentCourse = Personal.nextLine();
System.out.print("Other Course: ");
String oc = Personal.nextLine();
System.out.print("Enter your gender: ");
gender = Personal. (5.) _____________ ();
System.out.print("Enter your Age: ");
age = Personal. (6.) _____________ ();
System.out.println("*********************************************");
System.out.println("PERSONAL PROFILE");
System.out.println("--------------------------------------------");
System.out.println("Name: " + FN +"\t" + MN + "\t" + LN );
System.out.println("Course: " + (7.) _____________ + "\t and \t" + oc );
System.out.println("*********************************************");
System.out.println("Gender: " + (8.) _____________ + "\n");
System.out.println(prog + " " + (9.) _____________ );
}
}
Sample INPUT:
Sample OUTPUT:
--------------------------------------------
PERSONAL PROFILE
--------------------------------------------
Name: Eddiemar Garcia Sinco
Course: MSCS and BSCS
--------------------------------------------
Age: 123
Gender: Male
B. Identify the output. Analyze the following Java codes and then give the correct
values of each variables. Write your answers on the space provided based on the
code's logic and calculations.
//PROCESS
int sum = x + y +z ;
int product = z * a ;
float dif = sum - a ;
double quotient = (product / sum) ;
float average = sum / (float)3 ;
//OUTPUT
System.out.println("\nSUM: " + sum);
System.out.println("Product: " + product);
System.out.println("Difference: " + dif);
System.out.printf("Average: %.4f\n", average);
System.out.printf("Quotient: %.3f\n", quotient);
}
}
For 1-6.
import java.util.Scanner;
/**
*
* @author Eddiemar
*/
public class Midterm_Exam
{
public static void main(String [ ] args)
{
double minutesInYear = 60 * 24 * 365;
System.out.println((int) min + " minutes is approximately " + years + " years and " +
days + " days");
}
}
D. Coding. Create a program that will be able to compute area of a triangle using the
following formula: Area = (width*height)/2.
Fundaments of Programming
Criteria 20 16 12 8 4 1 0
Program Completely Somewhat Somewhat Rarely Rarely Didn’t No
Code understands understands understands understands understands understands codes
the use of the use of the use of the use of the use of the use of
variables and variables and variables and variables and variables and variables and
their syntax their syntax their syntax their syntax their syntax their syntax,
in a Java in a Java in a Java in a Java in a Java it didn’t run
program program with program with program with program with
Criteria 20 16 12 8 4 1 0
1 error 2-3 error only 4-5 6-7 errors
errors
Prepared by:
Faculty Faculty
Reviewed by:
Reviewed by:
Approved: