The Switch Statement Decision Statement Part-3 JAVA-LEC07
Автор: Kiet Patna
Загружено: 2021-12-07
Просмотров: 1237
Описание:
JAVA PROGRAMMING LECTURE N0-07
Decision Making Statements Part-3.
2)The switch statement
Java has a built-in multi-way decision statement known as a switch. The switch statement tests the value of a given variable( or expression) against a list of case values and when a match is found, a block of statements associated with the case is executed.
Syntax :-
switch (expression )
{
case value-1:
block-1;
break;
case value-2:
block-2;
break;
…………….
……………..
default :
default block;
break;
…………………
}
Q-No-1: Write a JAVA program to perform Mini Calculator using Switch case.
Q-No-2: Write a JAVA program to check whether the given Character is Vowel or Not.
Q-No-3: Write a JAVA program to perform Arithmetic Operator using Switch case.
Decision Statements
The decision statement decides the statement to be executed after the success or failure of a given condition. The decision-making statement checks the given condition and then executes its sub-block.
Java language possesses decision-making capabilities supporting the following statements ;-
1. if statement
2. switch statement
3. conditional operator statement
These statements are popularly known as decision –making statements. Since these statements control the flow of executing, they are also known as control statements.
a) The if statement
b) The if-else statement
c) Nested if-else statement
d) The if-else-if ladder statement
a) The if statement
Java uses the keyword if to execute a set of command lines or one command line when the logical condition is true. It has only one option. The set of command lines or command lines are executed only when the logical condition is true.
Syntax :
if(condition)
statements;
e.g,
2. The if..else statement
The if..else statement takes care of true as well as false conditions. It has two blocks. One block is for if and it is executed when the condition is true. The other block is of else and it is executed when the condition is false. The else statement cannot be used without if. No multiple else statements are allowed with one if.
Syntax :
if(condition)
statement1;
else
statement2;
Nested if..else
if(condition)
statement;
else
statement;
else if(condition)
statement;
else
statement;
The if..else if ladder
Syntax :
if(condition1)
statement;
else if(condition2)
statement;
else if(condition3)
statement;
…………………….
else
statement;
e.g,
Please subscribe my channel for getting video related to information technology.
https://www.youtube.com/channel/UCbSg...
Follow on Facebook: / kiet-patna-1. .
Follow on Instagram: / nasim.raja.10
Download KIET PATNA App.
Patna's Top IT training Institute!!
https://play.google.com/store/apps/de...
/ @kietpatna3180
#KIETPATNA #KHADIJAHINSTITUTEPATNA #SOFTWARETRAININGKIETPATNA
Повторяем попытку...

Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: