Java Programming 3rd Quarter
Java Programming 3rd Quarter
Department of Education
Region VII, Central Visayas
DIVISION OF CITY OF BOGO
CITY OF BOGO SCIENCE AND ARTS ACADEMY
St. Joseph Vill., Cogon, Bogo City, Cebu
TEST III. OUTPUT TRACING. Generate the output of the following code.
n = n-- - --n;
System.out.print(‘n’);
System.out.print(m--);
}
22.) public static void main(String args[]){
int v = 10;
int w = v;
v = v + --w;
w = w * 0;
System.out.print(v);
System.out.println(w);
}
23.) public static void main(String args[]){
int y = 2, v = 5;
System.out.println(“v * y”);
System.out.printf(v + “ ” + (v%y));
}
24.) public static void main(String args[]){
int i = 6, j = 9;
j = 0;
i = i-- + j – i;
System.out.println(i);
}
25.) public static void main(String args[]){
int n = 8, u = 3;
n = n-- % n;
u = --u * u;
System.out.print(u++);
System.out.print(n++);
}
TEST IV. FINDING THE ERROR. The following Java Program is riddled with errors. Encircle all the errors you can find. Be
specific as possible as you can. The highest possible score is 20/15. Right minus Wrong.
/*
A local pizza house is offering a discount-treat to its customers according to their age:
MINORS - 10%, SENIOR CITIZEN - 5%
The regular prize of a pizza is P350.00.
Create a java program that accepts an age of the customer and outputs the discounted
amount of pizza the customer should pay.
*/
Import java.util.scanner;
class PizzaDiscountIfElse{
int age = 0
double discountedAmount = 0.0;
Scanner ageScanner = new Scanner(system.in);
TEST V. CODING: Create a Java Program for the following problem / situation. Write your answer at the back.
Write a Java program that accepts two numbers from the user and checks if the first number is a factor of the
second number. Refer to the sample output below.