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









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   ... statement in our JSP code. switch_statement_jsp.jspADS_TO_REPLACE_2...;num").charAt(i); // switch statement with some value switch(value
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
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
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.... To avoid this we can use Switch statements in Java. The switch statement is 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 in java
: In the above code switch case have multiple option unlike if else case, depending... block. A statement in switch is labeled with one or more case or default...Switch case in java In this section we will learn about switch case 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
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 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
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
Need the Following MobileApplication Related Code
: and one Daemon Thread class need's to run while doing the above operations and if you can provide code in switch cases,I feel more happy. Please reply me ASAP.ADS...Need the Following MobileApplication Related Code  Hi, I need java
Switch statement in PHP
Switch statement in PHP  HII, Explain about switch statement in PHP?   hello,ADS_TO_REPLACE_1 Switch statement is executed line by line. PHP executes the statement only when the case statement matches the value
need code - Java Beginners
need code   i want to take the html coding. if user give a input html file the out is html coding in text file. i want to take html coding only... are sending you a sample code which will be helpful to you. import java.io.
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 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
code need - Java Beginners
code need  hi i want to code doing for this. If i have enter the text...)  Hi Friend, Try the following code. We hope this will help you...")); } matcher.appendTail(sb); String[] fields = sb.toString().split(","); for (int i=0;i
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" %>
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
Need source code - Swing AWT
Need source code  Hai friends, How can I, view all..., Try the following code: import java.awt.*; import java.sql.*; import... data"; Statement stmt = connect.createStatement
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
Switch case + condition??
Switch case + condition??  I try to use a switch case with condition..._TO_REPLACE_1 I need a help...(); } } else { List down = (List)display.getCurrent(); switch
Need source code - Swing AWT
Need source code  Hai, I need a source code for developing the project, title is "Face Recognition" and the backend as My-sql.... Thanks & Regards
need java code - Java Beginners
need java code  I want java code for connect to bit.ly and our link is converted into shorten link and give me response. as a converted link
NEED CODE FOR APPLICATION - Development process
NEED CODE FOR APPLICATION  i want to build a supermarket software that has the features of stock taking and receipt priting. can u help me
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 source code - Swing AWT
Need source code  Hai, I need a idea and code for developing the project "Face Recognition" with the backend as My-sql.... Thanks & Regards
need a Sample code - Development process
need a Sample code  i want run the python script in java code by using Runtime class and output should be formed like XML format.please help me. Advanced Thanks, Krishna
Java switch statement
Java switch statement  What restrictions are placed on the values of each case of a switch statement
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
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
Need Java Source Code - JDBC
Need Java Source Code  I have a textfield for EmployeeId in which the Id, for eg: "E001" has to be generated automatically when ever i click... be implemented.  Hi friend, Please send me code because your posted
java - need code - Java Beginners
java - need code  i am java developer. i want to remove file from one folder and same file is paste another folder. i need this code. (java)  hi, I am sending you the code which moves the file from one folder
Need source code - Swing AWT
Need source code  Hai, In java swing, How can upload and retrieve... image in database, try the following code: import java.sql.*; import...", "root"); Statement stmt = con.createStatement(); ResultSet rs = stmt
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
need java code - Java Beginners
need java code  i want a program for an algorithm in java which is it has some transactions T1=ABCE T2=CDE T3=DE T4=CDEG T5=BG T6... result . For this algorithm i need a program can any help me

Ads