Java Coding Problem

Java Coding Problem

View Answers

October 3, 2008 at 10:58 AM

Hi friend,


Solution 1 :

public class PrintNumber{
public static void main(String args[])
{
int num=1;
while(num<=40)
{
if(num%2==0)
{
System.out.print(" " + num + " ");
}
num++;
}
}
}

Solution 2 :

import java.io.*;
public class PrintDivsors
{
public static void main(String args[])throws IOException
{
int num;
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter Number:");
num=Integer.parseInt(in.readLine());
System.out.println();
System.out.println("Divsors:");
for(int i=1;i<=num;i++)
{
if(num%i==0)
{
System.out.print(" " + i + " ");
}
}
}
}

For more information on Java visit to :

http://www.roseindia.net/

Thanks









Related Tutorials/Questions & Answers:
coding problem - Java Beginners
coding problem  hi friend! Im new to jasper reports.how can i start that coding inorder to generate reports.can u send some sample programs for reporting?im badly need some clearly mentioned example because im new to jasper
coding problem - Java Beginners
coding problem  hi! i declared date as date datatype in oracle now i need to retrieve date from database to my java code.how can i please help me urgent   Hi Friend, We are providing you a code that will retrieve
Advertisements
coding problem - Java Beginners
coding problem  i had a big doubt. public ArrayList readExpenseType() throws ClassNotFoundException, SQLException,Exception { DBConnection dbc = new DBConnection(); Connection con = dbc.getConnection(); ArrayList
Problem in coding - Java Beginners
Problem in coding  How many times do you have to roll a pair of dice before they come up snake eyes? You could do the experiment by rolling the dice... friend, Code to help in solving the problem. public class Stimulates
coding problem - Java Beginners
coding problem  i used netbeans software to develop frame.now i need to add values to JList from ArrayList object  Hi Friend, Try the following code: import java.util.*; import javax.swing.*; public class
coding problem in netbeans - Java Beginners
coding problem in netbeans  hi, i have just started programming in netbeans,i'm facing a problem in a java application i create a jframe class and jbutton and jtextfeild inside it now i have created another class c1
Java Coding Problem - Java Beginners
Java Coding Problem  Q.1 How to write a while loop that displays all even numbers till 40? Q.2 How to write a method that accepts an integer...) { System.out.print(" " + i + " "); } } } } For more information on Java visit
problem in coding
problem in coding  i have a following code which display the contents of the text file but not other program like java or any c program is there any handler to open the program files other than Filereader. FileReader fr = new
problem i coding
problem i coding  i have a problem in coding a combobox containing a number of *.java program on click one of them that program should compile and run and display the result in other window
Java Programming and Coding problem - Java Beginners
Java Programming and Coding problem  How write a program that helps the user count his change. The program should ask how many quarters the user has, then how many dimes, then how many nickels, then how many pennies
Please provide the coding for this problem
Please provide the coding for this problem  Please provide the coding for the following problem. Write a "hangman" game that randomly generates a word and prompts the user to guess one letter at a time. Each letter in the word
coding problem - JSP-Servlet
coding problem  dear sir i m very new to JSP sir i m getting problem in dynamically changing the option of combobox from database(ms acess) .and after that option being selected for that the record from the databse should
Problem about coding in ajvascript
Problem about coding in ajvascript  I created a three radio buttons in the following way How many iphone styles are present in the image? <input type="radio" name="option" id="option" value="01" /> 01<br />
coding problem - JSP-Servlet
coding problem  dear sir will u plz tell me how can we delete a record from the database(MSaccess) when option in the combobox is selected(jsp)  If u want to delete the record from database, by seleting
coding problem - JSP-Servlet
coding problem  Dear sir i m very new to JSP .I am using two conbobox .if any option is selected in first combobox then only its data from the database should be displayed in other combobox, means how can we refresh
Please provide coding for following problem
Please provide coding for following problem  Please provide the coding for the following problem: You will write a java program that will read data from a file. The data in the file will be: John Doe 75 Joe Blow 65 Mary Smith 80
problem in writing coding. Please help me.
problem in writing coding. Please help me.  Hi sir, my name is Logeswaran. I have problem in writing JSP coding for my university assigments. Actually I'm doing a Voting System. I need to know how to write JSP coding
Java Coding
Java Coding  Hello, Can u please tel me how to improve my coding techniques.I am feeling difficulty with coding but I am perfect with my theory part
coding problem using vb and access - Security
coding problem using vb and access  i have problem on coding using vb on register button.when i click the label link it will terminate that program.so hard for me.i have no idea. then i also have problem on update,delete and add
problem to do coding upload image in php
problem to do coding upload image in php  can i get example coding how to upload image in php?i have try it but i dont no wheter it is correct or not because i can't save the image in folder and not connected to database mysql
coding in java
coding in java  write a code to calculate the product of odd integers from 1-15   class ProductOfOddIntegers { public static void main(String[] args) { long product=1; for(int i=1;i<=15;i
java coding
java coding  Hi sir, WRITE A PROGRAMME TO MAKE EMPLOYMENT MANAGMENT HAVING COLORS AND FRAME IN IT,???? CAN U SUGGEST ME HOW TO MAKE IT IN CORE JAVA
java coding
java coding  sir i need code for how to send meg from one system to another system
java coding
java coding  i need to to a project in java and the title is file parsing. i need to read a file or if a particular file is given i have to count the no of vowels, pick out some terms, and to display the details about that file
java coding
java coding  i am using netbean to my project and it is Desktop Application.i want my textfield to accept only numbers or only alphabets .........plez plez plez do help me..........i am just beginner to java codes
java coding
java coding  Hai,I am having order table in mysql database.when user click download button the order table data shows in csv format.Its very urgent.please help me. Thanks in advance
java coding
java coding  i have source code for my project virtual classroom. i need a little guidance to run that code..do help me out
java coding
java coding  using swing i want to give an exit button which on clicking ask a msg "JOptionPane" is select "yes" then it should exit or else not....plez help me...... JOptionPane.showConfirmDialog(null,"DO YOU REALLY WANT
JAVA coding
JAVA coding  using classes and arrays implement the following create classes, inheritance, object and execute methods. there are 5 students in a class, capture the surname, first name, age and sex. capture their marks of a given
java coding
java coding  plz correct this one ....i want to retrive data row from databse ...all its working but for combobox it not.......plz plz plz help me...... private void jButton4ActionPerformed(java.awt.event.ActionEvent evt
java coding
java coding  (person, student,employee, faculty and staff are classes) design a class named person and its two subclasses named student and employee    class Person { public String name; public String address; public
java coding
java coding  can any one plez tell me how to retrive a row from access to each field of swing... i hav tried this but i am getting an SQL error "SQLExceptionOccurred[Microsoft][ODBC Microsoft Access Driver]COUNT field incorrect
Java coding - WebSevices
Java coding for web services  How to start Java Coding for web services
j2me coding - Java Magazine
in sms using j2me. i have a problem in coding for sending and receiving sms .i have a coding for receiving sms but it not work because that program need sending sms using port no.please give me a solution for this problem............ give me
Image using Java coding
Image using Java coding  Hai, Display image in pdf file using Java coding through Xsl file.. Please help me.. xsl file generate the pdf file
coding - Java Beginners
coding  i need to start coding but i don't know how to start it so plz help me  Hi Friend, Please visit the following link: http://www.roseindia.net/java/ Thanks
color coding in java
color coding in java  hii..can anyone please help with auto coloring code in java swings..??a particular text field should have a particular color for a particular event..plzz help
single frame coding in java
single frame coding in java  sir, i am a beginner in java.i want to do a desktop application in java in which a single frame satisfies all needs.but i want changes in that frame only.how can i solve this?i think multiple frames
java coding - Java Beginners
java coding  dear sir, i'm doing a java coding using with netbeans ide, so i'm trying to pass some text from one jframe to another jframe which is both are already opend on screen then how to do it? please send me
Coding - Java Beginners
Coding  How to do a coding to view employee name, salary and EPF. The EPF is calculated from the salary like 10% from their salary. and it also show... the technologies you create the application in Java/JSP/Servlet/JSF/Struts
coding - Java Beginners
coding  i need start coding but don't have any idea to start plz help me
coding related - Java Beginners
coding related  what is the purpose of using these line in a program? char units = args[1].charAt(0); units = Character.toUpperCase.../java/java-conversion
Plz give java coding for this
Plz give java coding for this   ****** * * * *********** * * * ******   Hello Friend; below is the code : public class Pattern { public static void main(String[] args) { int
java coding help plz ?
java coding help plz ?  Given two integers N and M (N ΓΆβ?°Β¤ M), output all the prime numbers between N and M inclusive, one per line. N and M will be positive integers less than or equal to 1,000,000,000. The difference
Java while coding - Java Beginners
Java while coding  Java loop and function coding question? How can I write an application that accepts a person's weight and displays the number..., Code to help in solving the problem : import java.io.*; class Computation
java coding for creating table in the console
java coding for creating table in the console  write a java program to create table
Java Coding - Java Beginners
Java Coding  How do I do the following: Code an if/else statement...; Hi friend, Code to solve the problem : import java.io.*; class...); } } Thanks   Hi friend, Code to solve the problem
Java Coding - Java Beginners
Java Coding  How do I code the following: Code a private static method named getUPSShipping that accepts a double value named weight...; and 3.50 otherwise.  Hi friend, Code to solve the problem : import
Java Coding - Java Beginners
Java Coding  Write a program containing two functions, bubbleSort( ) and mergeSort( ). Each function should take an array of integers, sort the array... the problem : public class bubbleSort{ public static void main(String a[]){ int
Java Coding - Java Beginners
Java Coding  How do I code the following? Code an if/else statement that tests the value of a string variable named shippingMethod to determine... the problem : import java.io.*; class ShippingMethod1 { public static

Ads