Professional Documents
Culture Documents
ICT 9 Modules 1 8
ICT 9 Modules 1 8
LEARNING COMPETENCIES:
1. Differentiate variable from data type; and
2. Apply variable and data type in creating program.
3. Apply arithmetic operators
4. Apply comparison operators
5. Apply the conditional statements
LEARNING TARGET:
I can apply the use of variables, data types, and arithmetic operators in creating programs.
MATERIALS:
internet
email
INSTRUCTIONS:
1. Study the information below:
Relational operators are used to check the relationship between two operands. If the relationship is true the
Operato
Operator Name Example
r
The if Statement
Use the if statement to specify a block of C# code to be executed if a condition is True.
Syntax
if (condition)
{
// block of code to be executed if the condition is True
}
Note that if is in lowercase letters. Uppercase letters (If or IF) will generate an error.
In the example below, we test two values to find out if 20 is greater than 18. If the condition is True, print
some text:
Example
if (20 > 18)
{
Console.WriteLine("20 is greater than 18");
}
We can also test variables:
Example
int x = 20;
int y = 18;
if (x > y)
{
Console.WriteLine("x is greater than y");
}
Example explained
In the example above we use two variables, x and y, to test whether x is greater than y (using the > operator).
As x is 20, and y is 18, and we know that 20 is greater than 18, we print to the screen that "x is greater than y".
Example
int time = 20;
if (time < 18)
{
Console.WriteLine("Good day.");
}
else
{
Console.WriteLine("Good evening.");
}
// Outputs "Good evening."
Example explained
In the example above, time (20) is greater than 18, so the condition is False. Because of this, we move on to
the else condition and print to the screen "Good evening". If the time was less than 18, the program would
print "Good day".
2. Open any browser and type this address https://dotnetfiddle.net/. Press enter to load the page.
TRY THIS:
Create a program that checks the qualification of the age below:
Age Condition Remark
19 and above You are legally qualified to vote!
18 You are exactly 18. You are qualified to vote!
0 to 17 I'm sorry, you are below 18. You cannot vote yet.
Less than 0 Invalid Age
Guide Sample 1:
SYNTAX CODE:
using System;
namespace act_2_age_azarcon
{
class Program
{
public static void Main(string[] args)
{
double age;
Console.WriteLine("Programmed by: Adina D. Azarcon, 9G");
Console.WriteLine("");
else if(age==18){
Console.WriteLine("You are exactly 18. You are qualified to vote!");
}
else if(age>=17){
Console.WriteLine("I'm sorry, you are below 18. You cannot vote yet.");
}
else if(age<=0){
Console.WriteLine("This age is INVALID!");
}
Console.ReadKey(true);
}
}
}
OUTPUT
Guide Example 2:
CONDITIONS
using System;
namespace Act3_AgeGroup_LeeH
{
class Program
{
public static void Main(string[] args)
{
double age;
Console.WriteLine("Programmed by: Name and Section");
Console.WriteLine("");
if(age>=80) {
Console.WriteLine("Your generation is pre depression");
Console.WriteLine("Your date of birth is before 1930");
}
else if(age>=64) {
Console.WriteLine("Your generation is depression");
Console.WriteLine("Your born between 1930-1945");
}
else if(age>=45) {
Console.WriteLine("Your generation is baby boom");
Console.WriteLine("Your born between 1946-1964");
}
else if(age>=33) {
Console.WriteLine("Your generation is generation x");
Console.WriteLine("Your born between 1965-1976");
}
else if(age>=15) {
Console.WriteLine("Your generation is generation y");
Console.WriteLine("Your born between 1977-1994");
}
else if(age<15) {
Console.WriteLine("Your generation is generation z");
Console.WriteLine("Your born between after 1994");
}
Console.ReadKey(true);
}
}
}
OUTPUT:
Competencies:
Apply all the c# concepts in creating program.
Instructions:
See the sample output saved in the folder.
1. Create a new project with the filename: CN_LASTNAME.
Save the project inside the a folder.
2. Apply the necessary variables and data types declaration
and initialization.
double ______, ______;
Console.WriteLine("Programmed by: Name and Section");
Console.WriteLine("");
Console.WriteLine("___________");
_____=Convert.ToDouble(Console.ReadLine());
Console.WriteLine("___________");
_____=Convert.ToDouble(Console.ReadLine());
Rubrics:
Category 10 9 8 7
Specifications The program works and meets The program works and The program produces The program is
all of the specifications. produces the correct correct results but does producing incorrect
results and displays not display them results.
them correctly. It also correctly.
meets most of the other
specifications.
Efficiency The code is extremely efficient The code is fairly The code is brute force The code is huge and
without sacrificing readability efficient without and unnecessarily long. appears to be patched
and understanding. sacrificing readability together.
and understanding.
Delivery The program was 80-99% of the program 60-79% of the program 59% and below was
delivered100% on time was delivered within a was delivered within a delivered within a given
given time given time time
4 3 2 1
Information Information is creatively written Information is well Information could be Information is poorly
and cleverly presented. written and interesting to better written and too written, inaccurate, or
read and is presented in much information is incomplete.
short sections. given in each section.
Creativity Was extremely clever and Was well done and Was clever at times; Minimal effort. Poor
presented with originality. interesting to the incorporated most of the layout/design. Did not
Excellent layout/design work audience; added a few attributes; used a limited incorporate required
incorporating all required original touches to variety of appropriate attributes, graphics, did
attributes, great variety of enhance the project; graphics. not resize pictures,
appropriate graphics that used a good variety of
enhanced the pages. appropriate graphics.
Work Ethics You worked very hard on your You worked hard on You worked on your You did not seriously
project and were always on your project but project but were off task work on your project,
task. sometimes got off task and needed to be you frequently were off
redirected by the task, and did not
teacher refocus when
redirected by the
teacher
Time Allotment Used time well during each Focused on getting the Needed numerous Did not use class time
class period. Focused on project done, but was reminders to get back to to focus on the project.
getting the project done. Did occasionally distracted work.
not distract others. Helped or distracted others.
others.
Following Able to follow all the Able to follow majority of
Instructions instructions correctly the instructions
Total: 50 points