0% found this document useful (0 votes)
59 views

Week 2 As Ibarra

This document contains an activity on objects and input/output in Java. It includes marking true/false statements, answering questions, and programming exercises. The programming exercises involve: [1] Creating a JOptionDialogBox to get user input and display a sum; [2] Getting weight input in kg and outputting equivalent pounds to two decimal places; [3] Calculating and outputting an employee's monthly paycheck to a file with deductions and two decimal place formatting. It also provides a grading rubric for the programming exercises focusing on correctness, logic, efficiency, and syntax.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views

Week 2 As Ibarra

This document contains an activity on objects and input/output in Java. It includes marking true/false statements, answering questions, and programming exercises. The programming exercises involve: [1] Creating a JOptionDialogBox to get user input and display a sum; [2] Getting weight input in kg and outputting equivalent pounds to two decimal places; [3] Calculating and outputting an employee's monthly paycheck to a file with deductions and two decimal place formatting. It also provides a grading rubric for the programming exercises focusing on correctness, logic, efficiency, and syntax.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

COLLEGE OF ST.

CATHERINE OF QUEZON CITY

WEEK 2: Intro to Objects and Input/Output


Activity No. 2:
I. Mark the following as true or false.
1. A variable declared using a class is called an object. True
2. In the statement x = console.nextInt (); , x must be a variable. True
3. You generate a newline character by pressing Enter (return) on the keyboard.
False
4. The methods printf and format are used to format a decimal number to a
specific number of decimal places. True
5. If a program uses input and output dialog boxes, it must contain the statement
System.exit(0);. False
II. Answer the following questions:
1. How does the variable primitive type differ from a reference variable? Primitive
directly store data into their memory/ reference variable store the address of
the object containing the data
2. What is an object? Instance of the class
3. What does the operator new do? Used to instantiate an object
III. Consider the following statements, and answer the questions below.
String str = “ Going to the amusement park”;
char ch;
int len;
int position;

1. What value stored in ch using the following statement? A.


a. ch = str.charAt(0);
b. ch = str.chartAt(10);
c. len = str.length();
d. position = str.indexOf(‘t’);
e. position = str.indexOf(“park”);
2. What is the output of the following statements? B.
a. System.out.println(str.substring(0, 5));
b. System.out.println(str.substring(13, 22));
c. System.out.println(str.toUpperCase());
d. System.out.println(str.toLowerCase());
e. System.out.println(str.replace(‘t’, ‘*’));

IV. Programming Exercise:

Computer Programming 2
Activity Sheet 1
COLLEGE OF ST. CATHERINE OF QUEZON CITY

1. Using JOptionDiaglogBox, create a program that will ask the user to enter two
numbers and display their sum.
2. Write a program that prompts the user to enter the weight of a person in
kilograms and output the equivalent weight in pounds. Output both weights
rounded to two decimal places. (Note that 1 kilogram = 2.2 pounds.) Format
your output with two decimal places.
3. Write a program that calculates and prints the monthly paycheck for an
employee. The net pay is calculated after taking the following deductions:
Income Tax: 10%
SSS: 8%
Medicare: 5%
Pag-Ibig Fund: 7%
Your program should prompt the user to input gross amount and the employee
name. The output should be stored in a file. Format your output to have two
decimal places. A sample output as follows:
Juan Dela Cruz
Gross Amount: 10,000.00
Income Tax: 1,000.00
SSS: 800.00
Medicare: 500.00
Pag-Ibig Fund: 700.00
Total Deductions: 3,000.00
Net Pay: 7,000.00
Rubric for grading programming exercise.
Grading Rubric
Criteria Performance Indicators Points
Correctness The code produces the expected results 5
Logic The code meets the specifications of the problem 5
Efficiency The code is concise without sacrificing correctness and logic. 5
Syntax The code adheres to the rules of the programming language. 5
Total 20

Computer Programming 2
Activity Sheet 2

You might also like