i need to replace this if statement code with switch case code

Ads
 

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%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

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

Ads









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
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
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
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
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 of code
need of code  howto convert greyscale image to binary image 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 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
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
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 a JSP CODE
Need a JSP CODE  *Hi I need JSP source code for selling products which are in database.. please can any one help me ..URGENT* Thank You
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
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
Need a jsp code
Need a jsp code  I need a jsp code in which when i select a value.....please help me for this.   The given code retrieves the employee name... = "root"; String password = "root"; int sumcount=0; Statement st; try
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
need code for file browser
need code for file browser  hi, i need to write a code to browse the file in my computer using Jsp or java.. what is the code for file browser?   JSP Code for browsing: 1)page.jsp: <%@ page language="java" %>
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
I need help on my Java code.... please please help me out!?
I need help on my Java code.... please please help me out!?  Well my code is supposed to ask for an input file and then (ex: input.txt), read... need a part of the code thats fixed if possible! Heres is the code: import
I need jsp code for how to write text field value into property file.
I need jsp code for how to write text field value into property file.  Hi , I need to set the text field value into property file using jsp code. Example : Username : Valar , I have entered the value "Valar" in the text field
need code for login in asp.net with c#
need code for login in asp.net with c#  hai iam trying to develop a project in asp.net with c#,so i need a code for login page using which admin and other users can log in.plz help me, thanks in advance
need someone to do/help with code
need someone to do/help with code  i need someone to do a code for me..., I want a second class that is able to tell the owner how much he made that day, along with the number of items sold..please help did a code 500 times cant
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
i want code for these programs
i want code for these programs   Advances in operating system Laboratory Work: (The following programs can be executed on any available and suitable platform) Design, develop and execute a program using any
code
code   hi I need help in creating a java code that reminds user on a particular date about their festival. i have no clue of how to do it.. am looking forward to seek help from you
Can i write JavaScript code in AjaxResponse Code ?
Can i write JavaScript code in AjaxResponse Code ?  Hai Every Dynamic's We can't write JavaScript code in Ajax Response Code.Why because it takes...'s not working.rather than that i try to created on innerHtml document. here

Ads