This is very simple Java program for implementing the switch statement. Here, you will learn how to use the switch statement in your java program for developing java application. This section provides you the best illustration about some mathematical operations like Addition, Subtraction, Multiplication and division.
Program Overview And Result:
This section also provides you an example with complete java source code for understanding more about the switch statement in Java. The following java program tells you for entering numbers for involving in mathematical operations as your choice (whatever you want to do with both number). Four type of operations are listed through the program in sequence. Whatever you have to perform the operation firstly you have to enter you choice as an existing operation number for selecting operation what you want to do with entered two numbers.
Here we are going to make a program to follows the switch statement. For completion the example firstly we define a class named "SwitchExample" and two integer type values from users. Java I/O Package has a input Stream and a output Stream in which input stream is used for reading the stream and memory allocating . As in this program we are going to create a buffer for the string class that can be used to storing and processing a string character. Here in this program used the pursuing method for two integer value x and y. Now in this program use once again perform the parseInt method for Enter the choice number.
After that in this program we are going to use for the continue statement. This program take a number and check weather the number lies between 1 to 5. If the user enter the number 1 then the program print addition and enter the 2 then will be print subtraction so on up to 4 number otherwise when you user enter after 4 then will print "Invalid Entry" massage using by the println() method.
Here is the code of this Example
Rs. 20,000 US$ 300
Today: Rs. 10,000 US$150
Course Duration: 30 hrs
Posted on: June 8, 2007 If you enjoyed this post then why not add us on Google+? Add us to your Circles