Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners i need to replace this if statement code with switch case code
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


mohamed sadany
i need to replace this if statement code with switch case code
1 Answer(s)      4 years ago
Posted in : Java Beginners


i need to replace this code with switch case

for(int i=0;i<100;i++){ if((i%3)==0) system.out.println("java"); if((i%5)==0) system.out.println("technology"); if((i%15)==0) system.out.println("java technology");

}

thanks a lot


Advertisement
View Answers

January 6, 2011 at 4:02 PM


Hi Friend,

Here is your required code:

class Loops{
    public static void main(String[] args){
for(int i=0;i<100;i++){
    for (int j = 1; j <= i; j++)
{
if(i % j == 0){
switch(i/j){
          case 3:  System.out.println ("java");
                   break;
          case 5:  System.out.println ("technology");
                   break;
          case 15: System.out.println ("java technology");
                   break;
        }
}
}
    }
    }
}

Thanks



Related Tutorials/Questions & Answers:
i need to replace this if statement code with switch case code
i need to replace this if statement code with switch case code   i need to replace this code with switch case for(int i=0;i<100;i++){ if((i...){ switch(i/j){ case 3: System.out.println ("java
i need program or code for this program
i need program or code for this program  out should be in this form 1 2 3 4 5 6 3 5 7 9 11 8 12 16 20 20 28 36 48 64 112
Advertisements
How to use switch statement in jsp code
How to use switch statement in jsp code   ... code. switch_statement_jsp.jsp <HTML> <HEAD> <...); // switch statement with some value switch(value){ case '0': out.print
Find Capital using Switch-Case statement
Find Capital using Switch-Case statement In this Java Tutorial section, we are going to find the capital of our states using Switch-Case statement... state will get displayed on the console. Here is the code: import
PHP Switch Case
the statements until it found a break statement or the end of the switch case block...Switch Case Control Structure: Almost every modern language supports switch case control structure. It is similar to if statements. Switch case is useful
switch case
switch case  program to input 2 numbers and a choice.Using switch case we need to perform all the mathematical operation.Print a suitable error message if the choice is wrong
switch case
switch case  program to input 2 numbers and a choice.Using switch case we need to perform all the mathematical operation.Print a suitable error message if the choice is wrong
The Switch statement
. Here is the general form of switch statement: switch (expression){ case 1.... Then there is a code block following the switch statement that comprises... a statement following a switch statement use break statement within the code block
i need a java code for finding typemismatch in an editor.
i need a java code for finding typemismatch in an editor.  hi im sriram, i need a java code in such a way that typemismatch code is embedded with the simple java editor. the sample output is shown below !alt text
i need the source code to generate id in jsp
i need the source code to generate id in jsp  hai,i need the source code for generate id...which is i need to generate the new id from the maximum+1,like automatically when i click the button...as well i have several kinds
PLZ HELP ME. i need php code.
PLZ HELP ME. i need php code.   I want php code for bellow OUTPUT. output is just example but it must be letters only. abc bcd efg jku rgt azs hje qqc wws adt
Switch case in java
. A statement in switch is labeled with one or more case or default. If we talk about...Switch case in java In this section we will learn about switch case in java..., and java, switch case is used . switch  is a selection control mechanism used
switch statement
switch statement   i want to write a java program that computes Fibonacci,factorial,string reversal and ackerman using switch case to run as a single program
switch case instead of if else
switch case instead of if else  How to write code in switch case instead of if else in Java
Switch Statement
switch case statement. The program displays the name of the days according to user...Switch Statement  How we can use switch case in java program ?   Note:-Switch case provides built-in multiway decision statement.It
Switch statement in PHP
Switch statement in PHP  HII, Explain about switch statement in PHP?   hello, Switch statement is executed line by line. PHP executes the statement only when the case statement matches the value of the switch
i need attendce management system source code in java
i need attendce management system source code in java  i need attendance management system source code in java
need code
need code  Create Vehicle having following attributes: Vehicle No., Model, Manufacturer and Color. Create truck which has the following additional... is the required code: import java.util.*; class Vehicle { int
need code
need code  Create Vehicle having following attributes: Vehicle No., Model, Manufacturer and Color. Create truck which has the following additional... is the required code: import java.util.*; class Vehicle { int
need code
need code  Create Vehicle having following attributes: Vehicle No., Model, Manufacturer and Color. Create truck which has the following additional... is the required code: import java.util.*; class Vehicle { int
need of code
need of code  howto convert greyscale image to binary image in java
Switch case + condition??
Switch case + condition??  I try to use a switch case with condition...(); } } else { List down = (List)display.getCurrent(); switch(down.getSelectedIndex()) { case 0: Tambo(); if( label.equals
Java switch statement
Java switch statement  What restrictions are placed on the values of each case of a switch statement
Switch Statement with Strings in Java
Switch Statement with Strings in Java  Switch Statement with Strings in Java
using switch case
using switch case  Define a class MENU to perform the following operation depending upon the users choice using switch case 1)print square root... choice: "); int choice=input.nextInt(); switch(choice
Need an example of basic code.
Need an example of basic code.   Im working on an art project that I want to use some code in, and I am proficient in python but that looks fairly simple so I was hoping java would look more impressive. So I just need a visual
Need an example of basic code.
Need an example of basic code.   Im working on an art project that I want to use some code in, and I am proficient in python but that looks fairly simple so I was hoping java would look more impressive. So I just need a visual
Need an example of basic code.
Need an example of basic code.   Im working on an art project that I want to use some code in, and I am proficient in python but that looks fairly simple so I was hoping java would look more impressive. So I just need a visual
Switch case in Jsp page
Switch case in Jsp page  <table> <tr><td>Enter Distance :</td> <td><input type="text" name="dis"/></td>... using switch case in jsp page
need JSP Code.
need JSP Code.  **Hi I need JSP code for selling Products which are in Database. Please can any one help for this.URGENT... Thank You..! Abhijeet
Need sample code
Need sample code  Need code for graph which shows the performance comparission of aprior algorithm and coherent rule algorithm.plz can any one help me i need in a week
Advertisements
 

 

 

DMCA.com