 |
|
|
Posts: 17,781
Country:
Star Sign:
Join Date: Jul 2010
Location: ▌║█║▌│█│║▌║
Gender:
|
|
Calculator In Java Using Switch Statement
The switch Statement Is Used As A Reciprocal Of nested if else Statements. It Is Used When Multiple Choices Are Given And One Choice Is To Be Selected.
The 'nested if-else' Structure Becomes Complicated In Multiple Choices So Then We Used switch Statement.
One Of The Choices Or Cases In The switch Statement Is Executed Depending Upon The Value Returned By The Expression.
In The switch Statement The break Statement Is Normally Used At The End Of Statements In Each Case. It Exits The Control From The Body Of switch Structure.
If It Is Not Used Then The Statements Of Other Cases That Come After The Matching Case Will Also Be Executed.
Syntax
switch(expression)
{
case constant:
statement;
break;
}
Example Of Making A Calculator

Output
Addition

Subtraction

Multiplication

Division

➳ bE driveN wiTh puRpOse, Be r313n71355 in your alιgnмenт;
with excellence.
pAy n0 mInd to the ∂ιsιмραssισηε∂ เ๓ק๏tєภt ђคtєгร ♬
☣.. нoolιgan ☠
|