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%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
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
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
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 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
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
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
Java Switch Statement
then switch statement can be used. It checks your choice and jump on that case label... case value exist. Execution continues after the end of the switch statement... Java Switch Statement      
need java code for <company:loc="bang">
need java code for   hi i want to write code like , i used setAttribute method for this. but its showing ERROR: 'Namespace for prefix 'company' has not been declared.' javax.xml.transform.TransformerException
code
code  please provide code for custom tags.by using currdate tag we need to get current date?please give me code
code
code  i have four textboxes.whenever i click on up,down,left or down arrows then the cursor move to another textbox based on the key pressed.i want code for this in javascript
Switch Statement with Strings in Java
Switch Statement with Strings in Java  Switch Statement with Strings in Java
need pyspark lit function example code
need pyspark lit function example code  Hi, I want to use the lit... to use it. It will be very helpful for me if someone shares me the code of pyspark... code in your python file: from pyspark.sql.functions import lit After that you
Need a Code to calculate hair density in java
Need a Code to calculate hair density in java  Hello, Would you please give me a code to calculate the hair density on scalp from image in java
Code
<%@page language="java"%> <% int k = 1; for(int i=1; i<= 4 ;i++){ for(int j=1; j <= i ; j++){ out.println(k+" "); k = k + 1; } out.println
Code
Code  code for connecting c lang to database
code
code    how to write this in java
code
code  code for android sample program
code
code  Heris the javascript code.It works ffine but i would like... this(in bold) because when i remove them and try calling the functions via object I am not able to do so. Is it always necessary to do this when using function
code
the correct code for a program.The output of the program is listed below...: {Block 5} ADDRESS-3: {San Juan} POST CODE:{6745} ENTER CODE (XX TO stop) CODE:{FF1} QUANTITY:{2} CODE:{TR4} QUANTITY:{1} CODE:XX INVOICE FOR YOUR ORDER Harry
code
code to create the RMI client on the local machine: import java.rmi.*; public... : "+e); } } } However, when the preceding code is executed it results... the correct code
code
line of code to print the amount he should be paid as allowance
need help to remove and optimise the code for creating a page
need help to remove and optimise the code for creating a page   i have the following code but it has some sorts of error whenever i run the page after validation through javascript it calls for the servlets and then i tried
Switch Case in Java
A statement in the switch block can be labeled with one or more case or default labels... case will take place. Example of Switch Statement in Java: import java.io.... if-then and if-then-else statements. As switch statement allows in-numerous possible execution paths
What is the difference between an if statement and a switch statement?
What is the difference between an if statement and a switch statement?   Hi, What is the difference between an if statement and a switch statement... values). Whereas the Switch statement offers you multiple choice of option from

Ads