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

 
 


mohamed sadany
i need to replace this if statement code with switch case code
1 Answer(s)      2 years and 4 months 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");

}

my email:mma_elsadany@yahoo.com 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 Pages:
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
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
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
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
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
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 - Overview
enclosed in braces.. The switch statement executes the case corresponding... after the end of the switch statement. case The case..." for the switch statement. It is written after the last case be convention
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
Switch Statement example in Java
Switch Statement example in Java    ... the switch statement. Here, you will learn how to use the switch statement in your java... the switch statement in Java. The following java program tells you for entering numbers
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
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      
C Break with Switch statement
the second case i.e odd If you enter the number 6, the switch statement checks... C Break with Switch statement   ... with Switch-Case in C. The switch case statements allows to control complex
Switch
. Then there is a code block following the switch statement that comprises of multiple case.... Here is the general form of switch statement: switch (expression){ case 1... a switch statement use break statement within the code block. However, its
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 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 functions - Java Beginners
switch functions  I am writing a script for use in a computer based... is clicked, I need the return to be an alert or write to the document... in the module. I need the alert to be written without trying to open internet
Strings in Switch statement
have matched string. The comparison of string in switch statement is case...Strings in Switch statement In this section, you will learn about strings..., you can pass string as expression in switch statement. The switch statement
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
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 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
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
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...Need the Following MobileApplication Related Code  Hi, I need java
Matching Case
Matching Case  Hi, i want some code for matching case from an text file. i.e if i give an query called Java from the user,i need to get an output searching the text file all the names in that without case sensitive
Java switch statement
Java switch statement  What restrictions are placed on the values of each case of a switch statement
if Statement - Overview
with if. [The other 1% of the decisions use the switch/case statement... statement. Reliability. When code is modified, the indentation... The if statement doesn't need braces if there is only one statement in a part
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
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
switch Java Keyword
of each case block to exit from the switch statement. -- If the break statement... :  -- The switch statement in java language enables the user to select..., byte, short or int. then only the execution of the switch case will start
Switch Case - Java Interview Questions
Switch Case  int x=100000; switch(x) { case 100000: printf("Lacks"); } output= Lacks I want reason why x matches switch case although range for int is in between something -32678 to +32676. Plz give me ans quickly
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
Break Statement in JSP
Statement in jsp</H1> <% for(int i =0; i <= 5; i++) { switch(i){ case 0: out.println(i+ "is zero."+"<br>"... are using the switch statement under which we will use break statement. The for loop
Calender code
Calender code  hi, this is my script, where do i add your script...(document, 'mouseup', Calendar.handleMouseUpEvent); Event.stop(event); }; // XXX I am not happy with how clicks of different actions are handled. Need to // clean
code problem - Java Beginners
code problem  Dear sir, my problem is that I've a string value if this String value has "quit" then output should be "bye". i want to make this program using SWITCH CASE statement. how to implement String value in Switch plz
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
save switch data into database - Java Beginners
save switch data into database  switch(menu) { case 1://add...(); switch(menu) { case 1: System.out.print("Enter student ID: "); int ID...:3306/register","root","root"); Statement st=con.createStatement(); int i
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
Java - The switch construct in Java
;    Switch is the control statement in java which.... In this Program you will see that how to use the switch statement... flow of control quits from the Switch block whenever break statement occurs
I need help in doing this. - Java Beginners
I need help in doing this.  Student DataBase i will need creating...() { switch (month) { case 4: case 6: case 9: case 11: if (day <= 30..., and the student's GPA.using arrays and objects, need to structure the information
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.
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" %>
using if and switch stmt - Java Beginners
be assumed. Write a program using "switch and if statement" to compute net amount...(); switch(menu) { case 1: System.out.print("Quantity: "); int q1 = scan.nextInt...using if and switch stmt  A cloth showroom has announced
Stymied with Java code - Java Beginners
for 0) { moves++; //set the br[cell] = curr_player; //use switch statement to determine if that move makes the user a winner switch(cell...Stymied with Java code  In dire need of help with my Tic Tac Toe

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.