Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 37

Riddles

• What is greater than God,


more evil than the devil,
the poor have it,
the rich need it,
and if you eat it, you'll die?
• What is greater than God,
more evil than the devil,
the poor have it,
the rich need it,
and if you eat it, you'll die?

ANSWER: NOTHING
• Which word in the dictionary is
spelled incorrectly?
• Which word in the dictionary is
spelled incorrectly?

ANSWER: INCORRECTLY
• What gets broken without being held?
• What gets broken without being held?

ANSWER: PROMISE
• He has married many women, but has
never been married. Who is he?
• He has married many women, but has
never been married. Who is he?

ANSWER: A PRIEST
• What has roots as nobody sees,
Is taller than trees.
Up, up, up it goes,
And yet never grows?
• What has roots as nobody sees,
Is taller than trees.
Up, up, up it goes,
And yet never grows?

ANSWER: MOUNTAIN
• I am the beginning of eternity, the end
of time and space. the beginning of
every end, and the end of every place.
What am I?
• I am the beginning of eternity, the end
of time and space. the beginning of
every end, and the end of every place.
What am I?

ANSWER: LETTER “E”


“If” Condition
What is “if” condition?
The simplest among all conditional
statements is the “if” statement. More
often than not, we face the
consequences of our decisions.

What is “if” condition?


For example, if we don’t eat then we
get hungry. The condition here is “not
eating”.

What is “if” condition?


When this condition is true, the
consequence is “we get hungry”. It is
the same with the “if” statement.

What is “if” condition?


If the condition in the “if” statement
is “true”, the succeeding statement will
be executed.

What is “if” condition?


With the “if” statement, you can also
execute several statement, just put them
within open and close braces.

Syntax:
If (<Boolean condition>)
{
<statement/s>
}
Example:
1 public class If_Statement
2{
3 public static void main(String[] args)
4 {
5 int x=0;
6 System.out.pintln(“Value is: “+x);
7 If (x%2==0)
8 {
9 System.out.println(“Value is an even number.”);
10 }
11 if(x%2==1)
12 {
13 System.out.println(“Value is an odd number.”);
14 }
15 }
16 }
Line 7
If (x%2==0)
 
Line 7 shows the “if” statement and its
condition. If the remainder when “x” is
divided by 2 is equal to 0, line 8 is
executed. Otherwise, it will immediately go
to next line after the close brace that marks
the end of the scope of the if statement: line
11.
Line 8-10
{
Systemn.out.println(“Value is an even number.”);
}

The open brace indicates the start of the


statements that will be executed if the condition
on line 7 evaluates to true. The close brace
marks the end of the statements to be executed
if the condition on line 7 evaluates to true.
Write a program that gives you result of
“passed” or “failed” if you enter the grade.

Test Data
 
Enter your grade: 83
 
passed
 
Exercises
Exercise 1: Write Java program to allow the
user to input his/her age. Then the program
will show if the person is eligible to vote. A
person who is eligible to vote must be older
than or equal to 18 years old.

Test Data
Enter your age: 18
You are eligible to vote.
Exercise 2: Write a Java program that
keeps a number from the user and
generates an integer between 1 and 7
and displays the name of the weekday. 

Test Data
Input number: 3 
Expected Output :
Wednesday
Task
Direction: Write this program on ¼ sheet of
paper. You can use any style of writing program
as long as it displays the same result. Time
allotment: 8 minutes.

Write a Java program that takes the user to


provide a single character from the alphabet.
Print Vowel or Consonant, depending on the user
input. If the user input is not a letter (between a
and z or A and Z), or is a string of length > 1,
print an error message.
Make an automatic computer for the
area of triangle.

Input base: 3
Input height: 2

Area: 3
Write a program that determines a
comparison between two group of
numbers using symbol <, >, and =.

Enter first digit: 3


Enter second digit: 2

Answer: >
• Study the else if statement on your
notebook.

Agreement
Problem #1
Write a program that automatically
computes for the perimeter of the rectangle.

Enter length: 10
Enter width: 5

Perimeter: 30
Problem #2
Make a program that gives you option of
beverages and lets you select from it.

Select beverages: 1-juice 2-sofdrinks 3-


water 4-coffee

Enter selection: 2

Beverage: softdrinks
Problem #3
Write a program that computes the cube
of the given number.

Enter number: 3

The cube is: 27


Problem #4
Write a program that computes your average from seven
subjects.

Enter English grade: 75


Enter Filipino grade: 82
Enter Math grade: 80
Enter Science grade: 83
Enter TLE grade: 77
Enter EP grade: 83
Enter AP grade: 81

Your total average is: 27

You might also like