Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
25 views

Computer Programming Module 3 Dacles

This document discusses the switch case statement in computer programming. It begins with an introduction and pre-assessment questions. It then provides examples of switch case statements in C#, C++, and Java programming languages. It includes activities for students to practice writing switch case statements. It assesses student understanding and has a reflection section for students to discuss what they learned.

Uploaded by

Jean Dacles
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Computer Programming Module 3 Dacles

This document discusses the switch case statement in computer programming. It begins with an introduction and pre-assessment questions. It then provides examples of switch case statements in C#, C++, and Java programming languages. It includes activities for students to practice writing switch case statements. It assesses student understanding and has a reflection section for students to discuss what they learned.

Uploaded by

Jean Dacles
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Computer

Programming
Quarter III – Module 3:
SWITCH ... CASE STATEMENT

Jesber Nabore
(Subject Teacher)

Zyra Jean D. Dacles


Grade 10 – Pythagoras (STE)
(Student)

PRE-ASSESSMENT
I. TRUE or FALSE
1. TRUE 6. TRUE
2. TRUE 7. FALSE
3. FALSE 8. TRUE
4. TRUE 9. FALSE
5. TRUE 10. TRUE

LEARN
1. SWITCH
2. CASE

ENGAGE
ACTIVITY 1
Programming Language Programming Language Programming Language
Name: Name: Name:
C# C++ Java

Syntax: Syntax: Syntax:


using System; #include<iostream> public class FirstJavaProgram

using name space std; {


namespace HelloWorld
/*This is my very first
{ program in Java.

class Program int main () * This Prorgram will


print 'Welcome user'*/
{ {

static void /* This is the hello


public static void
Main(string[] args) word program */
main(String []args)
{ {

cout << "Hello


Console.WriteLine("Hello World, Welcome to
World!"); TechVidvan! " <<
endl; // print System.out.println("Welcome
statement user"); // prints Welcome
}
user
} {

} return 0; }

Result: {

Hello World! Result:

Hello World, welcome


to TechVidvan!
APPLY
ACTIVITY 2: Understanding a Switch… Case Statement Program
1.
#include<stdio.h>

int main()
{
int score;

printf("Enter grade( 60-100 ): ");


scanf("%d", &score);

switch( grade / 100 )


{

case 10:
case 9:
printf("Grade: 95-100");
break;

case 8:
printf("Grade: 90-94");
break;

case 7:
printf("Grade: 85-89");
break;

case 6:
printf("Grade: 80-84");
break;

case 5:
printf("Grade: 75-79");
break;

default:
printf("Grade: 60-74");
break;

return 0;
}

Output for the test-case-1:-

Enter grade( 0-100 ): 95-100

Grade: 95-100-Outstanding

Output for the test-case-2:-

Enter grade( 0-100 ): 90-94

Grade: 90-94-Very Satisfactory

Output for the test-case-3:-

Enter grade( 0-100 ): 85-90

Grade: 85-90-Satisfactory

Output for the test-case-4:-

Enter grade( 0-100 ): 80-84


Grade: 80-84-Very Good

Output for the test-case-5:-

Enter grade( 0-100 ): 75-89

Grade: 75-79-Good

Output for the test-case-5:-

Enter grade( 0-100 ): 60-74

Grade: 60-74-Failed

2.

#include <stdio.h>
int main()
{
unsigned int week;
//Ask user to input week number
printf("Enter week number (1-7): ");
scanf("%u", &week);
if(week == 1)
{
printf("Monday");
}
else if(week == 2)
{
printf("Tuesday");
}
else if(week == 3)
{
printf("Wednesday");
}
else if(week == 4)
{
printf("Thursday");
}
else if(week == 5)
{
printf("Friday");
}
else if(week == 6)
{
printf("Saturday");
}
else if(week == 7)
{
printf("Sunday");
}
else
{
printf("Invalid Input! Please enter week number between 1-7.");
}
return 0;
}

Output:

Enter week number (1-7): 1


Monday

Output 2:

Enter week number (1-7): 14


Invalid input! Please enter the week number between 1-7.

ASSESS

Programming Language Name: Java

class Main {

public static void main(String[] args) {

int expression = 2;

// switch statement to check size

switch (expression) {

case 1:

System.out.println("Case 1");

// matching case

case 2:

System.out.println("Case 2");
case 3:

System.out.println("Case 3");

default:

System.out.println("Default case");

REFLECT

1. Today, I discovered that some of the programming languages uses the Switch…Case
Statement

2. I encountered difficulties in answering the syntaxes of the programming languages as well as


the coding, that’s why I use the internet to search how to do the activities.

You might also like