MIDTERM Exam - Programming 2 - 2SEM 2020

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 3

MIDTERM Examination 70 ITEMS. Important Reminders: To be submitted online typewritten using Microsoft Word.

Resend or Reupload this document with complete answer.

Enter your name here: > Daryl Andrada Course and Yr: BSCS 1B Date: May 2, 2020 Score:

TEST I: ONLINE MIDTERM EXAM - PROGRAMMING 2 – 2020 FILENAME: MIDTERM 45 points Typewritten

Problem:

Using Java programming language create the program in an array, number and string entry to generate the output below.
points:
OUTPUT:
No. Emp_Name Emp_Dept Hrs_Worked Hrly_Rate Liv_Allow Basic_Sal G_Pay SSS_Pre Medicare Tax_With Tot_Ded Net_Pay
m
1 Super, Man CCIS 100 150 900
2 Vol, Ta CCIS 200 160 700
3 Iron, Man MIS 150 170 800

Where:
1. Basic Salary = Hours Worked * Hourly Rate;
2. Gross Pay = Basic Salary + Living Allowance;
3. SSS Prem = P 300.00;
4. Medicare = P 150.00;
5. Tax_With = Grosspay * 0.05;
6. Total Deduction = SSS_Prem + Medicare + Tax_With; and
7. Net Pay = Gross Pay – Total Deduction;

Type your Answer here:


//Name of Programmer: Daryl Andrada
//Course and Year: BSCS 1B
//Date written: May 2, 2020
//Filename: MIDTERM

public class MIDTERM {


public static void main(String [] args) {
java.util.Scanner sc = new java.util.Scanner(System.in);
String array[][] = {{“No.”,
"Emp_Name","Emp_Dept","Hrs_Worked","Hrly_Rate","Liv_Allow","Basic_Sal","G_Pay","SSS_Prem","Medicare","Tax_With","Tot_Ded","Net_Pay"},
{“ ”, “ ” , “ ”, “ ”. “ ”, “ ”, “ ”, “ ”, “ ”, “ ”, “ ”, “ ”, “ ”},
{“ ”, “ ” , “ ”, “ ”. “ ”, “ ”, “ ”, “ ”, “ ”, “ ”, “ ”, “ ”, “ ”},
}
int No = 1;
for(int i = 1; i < array.length; i++) {
for(int a = 1; a < 6; a++) {
System.out.print("Input "+array[0][a]+" value: ");
array[i][a] = sc.next();
}
}
for(int i = 1; i< array.length; i++) {
array[i][0] = Integer.toString(No);
array[i][6] = Integer.toString(Integer.parseInt(array[i][3])*Integer.parseInt(array[i][4]));
array[i][7] = Integer.toString(Integer.parseInt(array[i][6])+Integer.parseInt(array[i][5]));
array[i][8] = "300";
array[i][9] = "150";
array[i][10] = Double.toString(Integer.parseInt(array[i][7])*0.05);
array[i][11] = Double.toString(Integer.parseInt(array[i][8])+Integer.parseInt(array[i][9])+Double.parseDouble(array[i]
[10]));
array[i][12] = Double.toString(Integer.parseInt(array[i][7])-Double.parseDouble(array[i][11]));
No++;
}
for(int i = 0; i < array.length; i++) {
for(int a = 0; a < array[i].length; a++) {
System.out.print("|"+array[i][a]);
for(int b = 0; b < 10 - array[i][a].length() ; b++) { //Para mag align sira into a table
System.out.print(" ");
}
}
System.out.println();
}
}
}
TEST II: Magic Square.
Problem: Create an 11 x 11 magic square, where all sides are equal. Write the total on each sides. 11 points points:
68 81 94 107 120 1 14 27 40 53 66
80 93 106 119 11 13 26 39 52 65 67
92 105 118 10 12 25 38 51 64 77 79
104 117 9 22 24 37 50 63 76 78 91
116 8 21 23 36 49 62 75 88 90 103
7 20 33 35 48 61 74 87 89 102 115
19 32 34 47 60 73 86 99 101 114 6
31 44 46 59 72 85 98 100 113 5 18
43 45 58 71 84 97 110 112 4 17 30
55 57 70 83 96 109 111 3 16 29 42
56 69 82 95 108 121 2 15 28 41 54

TEST III: Sudoku. Write the missing numbers to complete the nos. 1 – 9 in the table below without any duplication in a row, column, and in 3x3 box.

14 points points:
8 3 1 7 9 5 4 6 2
7 9 2 4 6 8 1 3 5
5 4 6 3 2 1 8 7 9
3 2 9 6 1 4 7 5 8
4 1 5 8 3 7 2 9 6
6 8 7 2 5 9 3 4 1
9 6 4 1 8 3 5 2 7
1 5 3 9 7 2 6 8 4
2 7 8 5 4 6 9 1 3

You might also like