Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners writing programs
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Janet
writing programs
1 Answer(s)      4 years and 5 months ago
Posted in : Java Beginners


1.write a program to display odd numbers from 1-50.


2.And Write a program to find the facorial of a number

Advertisement
View Answers

May 10, 2010 at 10:52 AM


Hi Friend,

1)
class OddNumbers{
public static void main (String args[]){
String oddNo = "";
for (int i = 1; i <=50; i++){
if (i % 2 != 0) {
oddNo += i + " ";
}
}
System.out.println("Odd Numbers between 1 to 50 are: "+oddNo);
}
}

2)
import java.util.*;
class factorial{
public static void main(String []args){
Scanner input=new Scanner(System.in);
System.out.print("Enter Number:");
int num=input.nextInt();
long fac=num;
for(int i=num;i>1;i--)
{
fac=fac*(i-1);
}
System.out.println(fac);
}
}

Thanks


Related Tutorials/Questions & Answers:
writing programs - Java Beginners
writing programs  1.write a program to display odd numbers from 1-50. 2.And Write a program to find the facorial of a number  Hi Friend, 1) class OddNumbers{ public static void main (String args
writing java programs - Java Beginners
writing java programs  How do i write a code to display even numbers from 1 to 50  Hi Friend, Try the following code: class EvenNumbers{ public static void main (String args[]){ String evenNo
Advertisements
programs
programs  give some programs on control statementds
Programs in java
Programs in java  Hi, What are the best programs in java for a beginner? Thanks
php programs
php programs  10 programs on varibles
java programs
java programs  Why word "static" is used in java programs
Java Programs
Java Programs  Hi, What is Java Programs? How to develop application for business in Java technology? Is there any tool to help Java programmer in development of Java Programs? Thanks
php programs
php programs  I need 15 programs on arithmetic operators with comments. Please help me
java programs
java programs  Explain types of Java programs. Also explain how to compile and run them.   Types of Java Programs: Standalone Applications Web Applications Enterprise Applications Console Application Web services
programs in java
programs in java  . I need an application for managing an educational institute. That application should provide the details of Students Courses Faculty Fee details etc.., pl z guide me how to write these programe
java programs
java programs  i need help in understanding the whole concept of the 13 java programs that i hav...here r de programs.. int i,j,m,n; m=Integer.parseInt(args [0]); n=Integer.parseInt(args [1]); System.out.print
c++ programs
c++ programs  i want the syntax for the following programs according to c++ pattern. 1.sum of multiples of an integer upto 10 2.2/4+4/6+6/8+8/10+.....n/n+2 3.1!/1+2!/2+3!/3+4!/4+...n!/n i just want the main logic as i m nt
java programs
java programs  A union B, transpose of matric, denomination of a given number i need java programs for this category?   Hi Friend, Transpose of matrix: import java.util.*; public class Transpose { public
Ghost Writing
Ghost Writing Ghost Writing is the kind of writing when someone... of writing it. So ghostwriter is a person who works behind the scene on a writing project in return of certain amount. The write-ups of the writer
Blog Writing
Blog Writing A blog, the short form of web log is an online user... on that. But the professionals are a better choice for writing the blog for commercial or promotional purpose. We provides the services of writing blogs for the commercial
Writing Actions
Writing Actions The Action is responsible for controlling of data flow within an application. You can make any java class as action. But struts have some built in interface and class for making action easily. To make an Action class
JSF Sample Programs
JSF Sample Programs  I need a JSF sample programs
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
how to execuite java programs???
how to execuite java programs???  I have jdk 1.6 installed in my pc.i want to execuite java programs in ms-dos for applet and without using applet.please tell me
how to execuite java programs???
how to execuite java programs???  I have jdk 1.6 installed in my pc.i want to execuite java programs in ms-dos for applet and without using applet.please tell me
Explain types of java programs
Explain types of java programs  Explain types of java programs   Types of Java Programs: Standalone Applications Web Applications Enterprise Applications Console Application Web services
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
Installing programs over a network
Installing programs over a network  Hi, i want to write a java program that will allow me to install programs from a server to a client machine. Any help will be appreciated. Thanks
RUNNING EJB PROGRAMS
RUNNING EJB PROGRAMS  how to run ejb programs using weblogic in windowsxp
dynamically writing text javascript
dynamically writing text javascript  dynamically writing text javascript. Is it possible
dynamically writing text javascript
dynamically writing text javascript  dynamically writing text javascript. Is it possible
Advertisements
 

 

 

DMCA.com