Central Philippine Adventist College
COMPUTER DEPARTMENT
Score
Computer Programming I
Prelim Examination – September 19, 2022
40
First Name M.I. Last Name
Read the Instructions carefully
Test I. Variable Declaration and initialization (20pts.)
1. Declare the variable “YES” with a data type String.
2. Declare the variable downpayment with assigned value 3,500 in data type integer.
3. Assign the value 25 to variable centavos in data type byte
4. Declare the variable playerNumber with a datatype float.
5. Assign the string “OK” to variable answer.
6. Assign the value 3.1415 to variable Pi in data type Double.
7. Declare the variable ‘N’ with a data type char
Test II. Debugging. Write Java if the statement is correct and Program if incorrect. Then encircle or write the
correct java code to make the statement correct. (20 pts.)
1. import java.swing.JOptionPane :
2. public class grade
3. {
4. public static volume main(String { } args)
5. [
6. strings midtermGrade;
7. String 123finalGrade ;
8. double midterm, final2;
9. double yourfinalgrade;
10. midtermGrade = JOptionPane.showMessageDialog(null, "Enter your midterm grade:
");
11. midterm=Double.parseDouble(midtermGrade)
12. finalGrade = JOptionPane.showInputDialog(null, Enter your final grade: );
13. final2=Double.parseDouble(finalGrade);
14. Your_finalgrade = ((midterm*0.40) + (final2 * 0.60));
15. JOptionPane.showInputDialog(null, "\n\n\n Your Final Grade is:" +yourfinalgrade);
16. System.exit(5);
17. }
18. }
- End of Exam -
Elnelyn C. Oberio, MIT, BSCS
Instructor