September 09, 2010, 02:02:46 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  Home Help Media Affiliates Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Using the swich statement in java  (Read 900 times)
0 Members and 1 Guest are viewing this topic.
G. Ritardo
Member
*
*

Reputation: 0
Offline Offline
Posts: 53
Referrals: 0

Awards
« on: May 31, 2009, 07:21:52 PM »

Code
GeSHi (java):
  1. public class SwitchExample {
  2.  
  3. public static void main(String[] args){
  4. int firstNumber = 2;
  5. int secondNumber = 1;
  6.  
  7. //you can change operation to + or -
  8. char operation = '+';
  9.  
  10. switch(operation) {
  11.    case '+':
  12.        System.out.println("The answer is " + (firstNumber + secondNumber));
  13.        break;
  14.    case '-':
  15.        System.out.println("The answer is " + (firstNumber - secondNumber));
  16.        break;
  17.    default:
  18.        System.out.println("Unknown operator used..");
  19.        break;
  20. }
  21. }
  22.  
  23. }
Created by GeSHI 1.0.7.20
Logged
My Contributions

Onzin > Email address of gaylords


Founder of www.Retardation-Foundation.com :: A community for retarded people!? Powered by admin Gaylord Ritardo.
Javaforums.net :: a community about Java software development.
« on: May 31, 2009, 07:21:52 PM »

 Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Your Ad Here
Powered by MySQL Powered by PHP Powered by SMF 1.1.10 | SMF © 2006-2009, Simple Machines LLC
TinyPortal v0.9.8 © Bloc
Valid XHTML 1.0! Valid CSS!
Page created in 0.185 seconds with 33 queries.

Google visited last this page September 07, 2010, 11:15:29 AM