Sei sulla pagina 1di 45

HOME MOVIES TV SHOWS SPORTS GENERAL RSSPRIVACY

Top of Form

iwebie.com

The Web

Bottom of Form

Logical Programs in Java Fibonacci Series, Prime Numbers Posted by admin on August 25th, 2008

Fibonacci Series
This Program generates Fibonnaci Series for a given number of times. Output: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 [sourcecode language='java'] public class FibonnaciSeries { /* * Generates the Fibonnaci Series */ public void generateSeries(int num) { int f1, f2 = 0, f3 = 1; System.out.println(fib(0) = + f2); for (int i = 1; i <= num; i++) { System.out.println("fib(" + i + ") = " + f3); f1 = f2;

f2 = f3; f3 = f1 + f2; } } public static void main(String[] args) { System.out.println("*****Fibonnaci Series*****"); FibonnaciSeries fb = new FibonnaciSeries(); fb.generateSeries(10); } } [/sourcecode]

Highest Prime Number


Given a number this program generates the highest prime number. Output: If the input is 25, the highest prime number close to 25 is 23. It prints 23. [sourcecode language='java'] public class PrimeNumber { /* * Given a number, finds the highest prime number. */ public static int highestPrime(int n) { int value = 1; for (int i = 2; i <= n; i++) { // System.out.println("n: " + n + " i: " + i + " mod: " + n%i); if (i == n) { value = n; break; } if (n % i == 0) { n--; } } return value; } public static void main(String[] args) { int value = highestPrime(25); System.out.println("Prime:" + value); } } [/sourcecode]

Triangle Printing
Given a number, this program prints the numbers in the right angle manner. Output:

1 23 456 7 8 9 10 11 12 13 14 [sourcecode language='java'] public class TrianglePrinting { /* * Prints the numbers in the right angle manner. */ public static void trianglePrinting(int n) { int counter = 0, i = 1; while (i <= n) { counter++; for (int j = 0; j < counter; j++) { if (i > n) break; System.out.print(i + ); i++; } System.out.println(); } } public static void main(String[] args) { trianglePrinting(14); } } [/sourcecode] Bookmark Article

166 Responses to Logical Programs in Java Fibonacci Series, Prime Numbers


1. rajnish Says: November 21st, 2008 at 10:44 pm

please send me the java program of prime number of Fibonacci series let us take e.g. 0, 1,1,2,3,5,8,13,.. den prime number series will be- 3,5,13
2. anil kumar dhatwalia Says: December 22nd, 2008 at 12:02 pm

amazing coding sir thanx


3. anil kumar dhatwalia Says: December 22nd, 2008 at 12:07 pm

please send me th java programe 1 3, 2 4. 5 7, 6 8, 9 11, 10 12;


4. sritej Says: January 2nd, 2009 at 1:06 pm

sir, i want simple logic of prime number programs


5. shweta Says: January 30th, 2009 at 12:52 pm

what is fibonacci series


6. Kiran Says: February 3rd, 2009 at 12:19 pm

hi, i want a logic program like 1 121 1231 12341


7. ramya Says: February 10th, 2009 at 5:10 pm

please send array using java


8. shankar Says: February 20th, 2009 at 2:15 pm

wowwwwwwwwwwwwwwww
9. nightfox Says: February 27th, 2009 at 8:48 pm

FibonacciSeries class would never compile , because of the blunders in the code Hope u can the see double n s used while creating a new instance of the class, It becomes a minimal etiquette to check the code (run it in u r machine ) as many of the newbies may take as reference and copy the same code and try to run it hope u take this in the +ve manner
10. Chandra Says: February 28th, 2009 at 7:00 pm

This is the output generated by the Fibonacci Series Program. It is 100% correct. Let me know what is the output u r getting. Lets consider v1= 5, v2 = 10, then v3 = 15 (i.e v1 + v2) v4 = 25 (i.e. v3 + v4) there on.. Fibonacci Series

*****Fibonacci Series***** fib(0) = 0 fib(1) = 1 fib(2) = 1 fib(3) = 2 fib(4) = 3 fib(5) = 5 fib(6) = 8 fib(7) = 13 fib(8) = 21 fib(9) = 34 fib(10) = 55
11. nightfox Says: February 28th, 2009 at 8:42 pm

Copy the same code that you have pasted ,u will get FibonnaciSeries cannot be resolved to a type
12. nightfox Says: February 28th, 2009 at 8:47 pm

Copy the same code that you have pasted ,u will get FibonnaciSeries cannot be resolved to a type error because of the spelling mistakes as u r class name is FibonacciSeries and u r instantiating a new object with FibonnaciSeries fb = new FibonnaciSeries(); (which contains single n and double cs) So i wondered did u ever run in u r machine
13. Moon Says: March 1st, 2009 at 10:38 am

Thanks for the correction. The program is updated.


14. Raja Says: April 29th, 2009 at 8:18 am

the second program will also be modified to be divided by 3 because if you take 21 as an example if you divide it by 2 it will say its prime number thou its not.. its divided by 3 .. I think we also need to add a if dividing the number with three..
15. venkat Says: May 28th, 2009 at 2:00 pm

/* 1 3, 2 4, 5 7, 6 8, 9 11, 10 12 */ import java.io.*; public class oddevenpair { public static void main(String a[]) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.print(Enter Number : ); int n = Integer.parseInt(br.readLine()); int odd[] = new int[2]; int eve[] = new int[2]; int o = -1, e = -1; StringBuffer sb = new StringBuffer(); for(int i=1; i<=n; i++) { if(i%2==0) {

e++; eve[e] = i; } if(e==1) { sb.append(eve[0] + + eve[1] + , ); e = -1; } if(i%2!=0) { o++; odd[o] = i; } if(o==1) { sb.append(odd[0] + + odd[1] + , ); o = -1; } } System.out.println(sb.delete(sb.length()-2, sb.length()-1).toString()); } }
16. venkat Says: May 28th, 2009 at 2:16 pm

/* 1 121 1231 12341 */ import java.io.*; public class inseq{ public static void main(String a[]) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.print(Enter a Number : ); int n = Integer.parseInt(br.readLine()); //Read the numeric input from console for(int i=0; i<n; i++){ for(int j=0; j0) { System.out.print(1); } System.out.println(\n); } } }
17. kavitha Says: June 17th, 2009 at 8:28 pm

please send the programs 1.display the factor numbers

2.display the prime number 3.display the 1 to 25 prime numbers


18. Nadhiya Says: June 27th, 2009 at 12:05 pm

send me a fibonaci series program in prime number


19. Nadhiya Says: June 27th, 2009 at 12:06 pm

program using fibonacci series in prime number


20. rohit Says: July 7th, 2009 at 9:06 am

want a program in java for a pyramid of 5 like: 1 12 123 1234 12345


21. Saurabh Says: July 22nd, 2009 at 9:44 am

HI i can do all types of pyramid programs !can u print a diamond in java 1 11 11 11 11 11 1


22. Saurabh Says: July 22nd, 2009 at 9:48 am

/* aprogram to display factors*/ import java.io.*; public class inseq{ public static void main(String a[]) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.print(Enter a Number : ); int n = Integer.parseInt(br.readLine()); int i, for(i=1;i<=n;i++) { if(n%i==0) { System.out.print(i); } } } }
23. loucil Says: July 23rd, 2009 at 3:09 pm

hi, i want a program like this

12345 1234 123 12 1


24. Cristina Says: July 27th, 2009 at 11:20 pm

Hi, ccan I ask how can I output this: 25 1 20 15 3 10 4 5 5 Please, I realy need it. Please help me! T.T
25. indresh Says: August 10th, 2009 at 5:16 am

input string=acasereeeeeeee hi,can i ask how can I output this 9 e Please, I realy need it. Please help me!
26. java_cub Says: August 12th, 2009 at 4:28 am

hi frns, can any one give the code to get the following output 1 23 456 7 8 9 10 11 12 13 14 15 16
27. Nels Says: September 13th, 2009 at 1:06 am

Please send me the java program for Infix to postfix and prefix expression..
28. saksham Says: September 14th, 2009 at 7:05 am

input string=acasereeeeeeee >input string=acasereeeeeeee >hi,can i ask how can I output this >9 >e >Please, I realy need it. Please help me! see you mean to input a String you need to input it.

//suppose s is String int hn=0; int c=0; int i,j; for(i=0;i<s.length();i++) {


29. saksham Says: September 14th, 2009 at 7:15 am

//remaining part char ch=s.charAt(i); //search for next now for(j=0;j<s.length();j++) { char chr=s.charAt(j); if(ch==chr) c++; } c; if(h<c){ h=c; //you have to take an //int variable and v=i; as //i forgot to take v in start. } } System.out.println(s.charAt(v)); //remember v System.out.println(h);
30. saksham Says: September 14th, 2009 at 7:20 am

hi frns, can any one give the code to get the following output 1 23 456 7 8 9 10 11 12 13 14 15 16 int c=1; int i,j; for(i=1;i<=4;i++) { for(j=1;j=1;i) { for(j=1;j<=i;j++) { System.out.print(c+" "); c++; }

System.out.println(); }
31. tushar bhakte Says: September 23rd, 2009 at 9:26 am

i want to always need for this


32. swapnali Says: October 2nd, 2009 at 11:47 am

hi, i want to knw the logic for permutation of string in lexicographic order like for String abc its permutation shud be abc acb bac bca cab cba
33. swapnali Says: October 2nd, 2009 at 11:49 am

hi, i want to knw the logic for permutation of string in lexicographic order like for String abc its permutation shud be abc acb bac bca cab cba
34. Subrat Says: October 20th, 2009 at 11:52 am

Any one can give me the calculate programming codes without useing conditions,loopig,swith case & Ternary Operator ?
35. ceejay Says: October 27th, 2009 at 12:12 pm

can u please help me for the code of this java problem: i want to display this 2 3 4 1+2 +3 +4 =1+4+27+256=288 thanks
36. ceejay Says: October 27th, 2009 at 12:13 pm

can u please help me for the code of this java problem: i want to display this factorial 1+2 +3 +4 =1+4+27+256=288 thanks
37. Rajdeep Says: November 2nd, 2009 at 2:33 pm

SOLUTION: 1 12

123 1234 . import javax.swing.*; public class NumAngle2 { public static void main(String[] args) { System.out.println(This program prints numbers in the right angle manner.); String input = JOptionPane.showInputDialog(Enter number?); int num = Integer.parseInt(input); int counter = 1; for(int i = 0; i < num; i++) { counter++; for(int j = 1; j < counter; j++) { System.out.print(j + " "); } System.out.println(); } } }
38. Rajarshi Banerjee Says: November 10th, 2009 at 5:35 am

Hey guys I am from India and I guarantee you that this Fibonacci number series program will work:import java.io.*; class fibonacci { public static void main(String args[])throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int num,ans1=1,ans2=0,ans3; System.out.println(Enter number); num=Integer.parseInt(br.readLine()); num=num-2; System.out.print(ans2); System.out.print( ); System.out.print(ans1); System.out.print( ); while(num!=0) { ans3=ans1+ans2; System.out.print(ans3); System.out.print( ); ans2=ans1; ans1=ans3; num=num-1; }

} }
39. Shweta Says: November 16th, 2009 at 2:15 am

hi friendz can anyone give me the code for the prog: to accept a string from the user and change the beginning letter of every word with a CAPITAL letter.
40. Rajdeep Says: November 19th, 2009 at 4:12 am

/* 1 121 1231 12341 */ import javax.swing.*; public class OneAngle { public static void main(String[] args) { String input = JOptionPane.showInputDialog(Enter num?); int n = Integer.parseInt(input); int count = 0; for(int i = 1; i <= n; i++) { count++; for(int j = 1; j 1) System.out.print(1); System.out.println(); } } }
41. sany Says: November 20th, 2009 at 1:20 am

can you help me how to figure out this java problem.. here is the output.. *** ** ** ** ** ***
42. sany Says: November 20th, 2009 at 1:21 am

___*** __*___* _*_____* _*_____* __*___* ___***


43. abhi Says: November 24th, 2009 at 10:48 pm

pls help, code required for the following number to word eg:- 1245 o/p:- one thousand two hundred forty five length of the input max 9.
44. sammy Says: December 9th, 2009 at 11:50 pm

F SERIES X=0,Y=1; PRINTF(X=%D Y=%D,X,Y); Z=X+Y; PRINTF(Z=%D,Z); X=Y; Y=Z;


45. Alok Says: December 24th, 2009 at 1:23 am

Hi Shweta, Ans to Q39: The best way is to use String.split().this returns array of strings(words in statement).Pick every word or index in array and modify first char using char(0) and toUppercase and join all array elements again. Hope that makes sense
46. pritam saraf Says: December 28th, 2009 at 4:37 am

Q 22. Using switch case perform array operation A. sorting of array no B. searching a particular no (taken as an input) C. Addition of total element in array. Q.23. Write a program that accepts a shopping list of five items from the command line and stores them in a vector. Q.24. Write a program, which will read a string and rewrite it in the alphabetical order. For example, the word STRING should be written as GNIRST Q 25. Write a program, which will take three strings from the command line and display the number of characters in each string. Q.26. Write a program to find out prime no from 1 to 100 Q.27. Write a program, which will read a text and count all occurrences of a particular letter. Q.28. Write a program to produce the following form. 1 01 101 0101 101011 22 333 4444 55555$$$$$

$$$$ $$$ $$ $ Q.29. Write a utility class to sort the employees according to their names. Q.30. Write a program to calculate harmonic value. e.g 1+1/2+1/31/n Q.31. Admission to a professional course is subject to the following conditions a. Marks in mathematics >=60 b. Marks in physics >=50 c. Marks in chemistry >=40 d. Total in all three subjects >=120 OR Total in mathematics and physics >=150 Given the marks in the three subjects, write a program to process the application to list eligible candidates. Q.32. Write a class Student; store it in the package stud. Write a class Batch with information about subject, faculty, and timing. Store it in the package bat. Use the class Batch to set information in the Student class. Q.33 Write a program to display Fibonacci series.e.g.. 1 1 2 3 5 8 13 21n.
47. pritam saraf Says: December 28th, 2009 at 4:38 am

Q 22. Using switch case perform array operation A. sorting of array no B. searching a particular no (taken as an input) C. Addition of total element in array. Q.23. Write a program that accepts a shopping list of five items from the command line and stores them in a vector. Q.24. Write a program, which will read a string and rewrite it in the alphabetical order. For example, the word STRING should be written as GNIRST Q 25. Write a program, which will take three strings from the command line and display the number of characters in each string. Q.26. Write a program to find out prime no from 1 to 100 Q.27. Write a program, which will read a text and count all occurrences of a particular letter. Q.28. Write a program to produce the following form. 1 01 101 0101 10101 1 22 333 4444 55555

$$$$$ $$$$ $$$ $$ $ Q.29. Write a utility class to sort the employees according to their names. Q.30. Write a program to calculate harmonic value. e.g 1+1/2+1/31/n Q.31. Admission to a professional course is subject to the following conditions a. Marks in mathematics >=60 b. Marks in physics >=50 c. Marks in chemistry >=40 d. Total in all three subjects >=120 OR Total in mathematics and physics >=150 Given the marks in the three subjects, write a program to process the application to list eligible candidates. Q.32. Write a class Student; store it in the package stud. Write a class Batch with information about subject, faculty, and timing. Store it in the package bat. Use the class Batch to set information in the Student class. Q.33 Write a program to display Fibonacci series.e.g.. 1 1 2 3 5 8 13 21n.
48. rani Says: January 2nd, 2010 at 2:59 am

PROGRAM TO PRINT A TRIANGLE AS FOLLOWS 1 12 123 1234 12345


49. rani Says: January 2nd, 2010 at 3:00 am

I NEED A JAVA CODE FOR 48TH QUESTION


50. psallm Says: January 13th, 2010 at 6:36 am

hi, yeah i need a fibonacii number series in loop.. can you help me???
51. mehul viramgama Says: January 17th, 2010 at 10:43 am

hi rani , PROGRAM TO PRINT A TRIANGLE AS FOLLOWS 1 12 123 1234 12345 import java.io.*; class ptn8 { public static void main(String arg[])

{ int i,j; for(i=1;i<=5;i++) { for(j=1;j<=i;j++) { System.out.print(j+" "); } System.out.println(""); } } }


52. lavanya Says: February 5th, 2010 at 1:10 pm

public class Fibonacci { public static void main(String []args) { int f1=0; int f2=0; int f3=1; System.out.println(The Fibo series is ::); System.out.println(f2); for(int i=0;i<10;i++) { System.out.println(f3); f1=f2; f2=f3; f3=f1+f2; } } }
53. lavanya Says: February 5th, 2010 at 1:13 pm

/* Prime nos generation as required by user::*/ import java.util.*; import java.io.*; public class prime_nos { public static void main(String []args) throws IOException { Scanner scan = new Scanner(System.in); int i,c,n; System.out.println(Enter the starting range ::); int a=scan.nextInt();

System.out.println(Enter the ending range ::); int b=scan.nextInt(); System.out.println(The prime nos are ::); for(n=a;n<b;n++) { c=0; for(i=1;i<=n;i++) { if(n%i==0) c++; } if(c==2) { System.out.println(n); } } } }
54. Elangovan ARUMUGAM Says: February 6th, 2010 at 1:54 pm

package com.maths; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; /** * Description: By definition, the first two Fibonacci numbers are 0 and 1, and * each remaining number is the sum of the previous two. Some sources omit the * initial 0, instead beginning the sequence with two 1s. * * In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the * recurrence relation Fn = Fn-1 + Fn-2 like F0= 0 and F1 = 1 * * F-n = (-1)power(n+1) * Fn * * Fibonacci Series: -8, -5, -3, 2, -1, 1, 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, * 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765 * * F(n+2) F(n+1) F(n) = 0 is similar to the defining equation of the golden * ratio in the form X*X -X -1 = 0; * * * * @author elangovan.arumugam * */ public class FibonacciTest {

/** * */ public FibonacciTest() { } /** * @param args */ public static void main(String[] args) { InputStreamReader inStream = new InputStreamReader(System.in); BufferedReader bufRead = new BufferedReader(inStream); int inputNumber = 0; List arrayList = null; try { int fib1, fib2, fib; System.out.println(*****************************************); System.out.println( Welcome to the Fibonacci Number Program ); System.out.println(*****************************************); System.out.println(Which Fibonacci Number do you want?); String inputNumberStr = bufRead.readLine(); inputNumber = Integer.parseInt(inputNumberStr); // System.out.println(Square Root of + inputNumber + : // + Math.sqrt(inputNumber)); fib1 = 1; fib2 = 0; switch (inputNumber) { case 0: System.out.println(Sorry, no result for f(0)); break; case 1: System.out.println(Fib(1) = 0); break; case 2: System.out.println(Fib(1) = 0); System.out.println(Fib(2) = 1); break; default: arrayList = new ArrayList(); arrayList.add(Fib( + (1) + ) = + 0); arrayList.add(Fib( + (2) + ) = + 1); System.out.print(0, 1); for (int i = 1; i <= inputNumber 2; i++) { // fib = 1 + 0 fib = fib1 + fib2; // fib2 = 1

fib2 = fib1; // fib1 = 1 fib1 = fib; System.out.print(", "); System.out.print(fib); arrayList.add("Fib(" + (i + 2) + ") = " + fib); } } System.out.print("\n"); System.out.println("Fibonacci Series :"); System.out.print(arrayList); } catch (Exception e) { e.printStackTrace(); } } }
55. Thulasipathi naidu Says: February 8th, 2010 at 1:05 am

how to convert input number 2542 .then output is disply like two thousan five hundred fourty two.
56. sagnik das Says: February 28th, 2010 at 4:29 am

1 12 123 1234 123 12 1 i know this program but i need something different like this 5 54 543 5432 54321 5432 543 54 5 can u give me the program for this
57. ravi Says: March 5th, 2010 at 2:21 am

write a program in java that accept a value n and calculate the sum of all odd number from n.
58. vikram Says: March 25th, 2010 at 8:14 pm

write a program for binary search


59. Surender Says: March 27th, 2010 at 1:06 am

1 3 2 4 5 7 6 8 9 11 10 12 answer to question 15th. It is so simple /* out put such as below 1 3 2 4 5 7 6 8 9 11 10 12 */ class PrintXY { PrintXY(){ for(int i=1;i<=10;i++) { if(i%2!=0) { System.out.print(i+" "+(i+2)+" "); } else { System.out.print(" "+i+" "+(i=i+2)+" "); } } } public static void main(String[] args) { new PrintXY(); } }
60. laxmi Says: March 29th, 2010 at 3:19 am

plz send me a pragram that accepts a character array and print the * for each character and also count the repeatable character and mark it by *. Input{a,b,a,b,c,d,a,c,a,b,d,f} output a**** b*** c** d** f*
61. alok Says: March 30th, 2010 at 1:56 am

these codes are useful but need some improvement


62. alok Says: March 30th, 2010 at 1:58 am

need some improvement


63. PJ Says: April 13th, 2010 at 11:43 am

Write a program in Java to print out the first n fibonacci numbers.

n will be the integer input given by the user


64. Abdul Sami Says: April 14th, 2010 at 11:09 am

very informative and appriciatable..


65. minox Says: April 19th, 2010 at 4:58 am

* ** *** **** ***** ******


66. Bhargav Says: April 21st, 2010 at 10:00 am

I want a program to find wether a number is prime or not using for and if..and also for finding factorial.
67. pema Says: April 23rd, 2010 at 12:01 pm

goood
68. Asma Says: April 24th, 2010 at 11:54 am

i need java code for the following: * ** *** **** plz help me in this..
69. lucy Says: May 10th, 2010 at 9:59 am

May i know the logic for Q1 1234554321 1234 4321 123 321 12 21 11 12 21 123 321 1234 4321 1234554321 Q2 1 1 12 1 12 123 1 12 123 1234 1 12 123 1234 12345 Q3 567898765 4567654

34543 232 1
70. Raghav Says: May 29th, 2010 at 1:05 am

what is mean of +i+


71. Reshma Says: June 2nd, 2010 at 7:57 am

1 01 101 0101 10101 1 22 333 4444 55555 $$$$$ $$$$ $$$ $$ $


72. jay Says: June 6th, 2010 at 12:57 am

what is the solution for 2+5+10+17+n times


73. jay Says: June 6th, 2010 at 12:59 am

and 1+4+27+16+125..n times


74. Peeru Says: June 8th, 2010 at 2:09 pm

this r not executing programs


75. latha Says: June 8th, 2010 at 11:38 pm

i need a solution for finding how many prime numbers between 200 10 300
76. Manoj Kumar Says: June 21st, 2010 at 9:23 pm

I want java code for : 1+3-5+7-9.n=result wil be see here where n is number of term 2> If the enter number is 153 then 1+125+27=153 then message will be show this armstrong number
77. shiv Says: June 28th, 2010 at 11:58 am

plz java code reply.this prog * **

*** **** *****


78. shiv Says: June 28th, 2010 at 11:59 am

* *** ***** ******* *********


79. shiv Says: June 28th, 2010 at 12:00 pm

54321 4321 321 21 1


80. shiv Says: June 28th, 2010 at 12:02 pm

1 121 12321 1234321 123454321


81. shiv Says: June 28th, 2010 at 12:05 pm

plz send coding in java.. write a prog.accept 10 element & display the 2nd highest no.
82. shiv Says: June 28th, 2010 at 12:07 pm

accept 10 element & display remove the dublicate no.. accept 7 element & display all element..
83. susheel Says: July 1st, 2010 at 2:46 am

find the sum of the following series (a) s=1+2/2*3+2+3/3*4+3+4/4*5..20terms


84. akshita Says: July 3rd, 2010 at 11:51 pm

hello.. this is akshita.. i want code for the output given below.. * *** ***** ******* ***** *** *
85. esther Says: July 4th, 2010 at 12:26 pm

may i know the logic for this output in any language c,c++ or java 11 12 21 123 321 1234 4321 1234554321 if anyone knows,pl do rply
86. raja Says: July 7th, 2010 at 5:23 am

how i find sum of digit apto single digit? please send the source code friends
87. naresh Says: July 11th, 2010 at 3:28 am

11 22 3 44 55 can u suggest me how to printit?


88. sharin Says: July 14th, 2010 at 8:26 am

i need an output like this: 1 121 12321 1234321 12321 121 1


89. sharin Says: July 14th, 2010 at 8:27 am

its a diamond. 1 121 12321 1234321


90. chandan Says: July 17th, 2010 at 4:51 am

java code for: 1 212 32123 4321234 543212345 4321234 32123 212 1

91. ram Says: July 17th, 2010 at 10:11 am

i want to display server time at client .plz


92. ram Says: July 17th, 2010 at 10:13 am

i want to disply server time at client side using simple socket program
93. swetha Says: July 18th, 2010 at 2:27 am

i need java program to delete a number in an array and to find the number of occurence of all the numbers in an array
94. anagha Says: July 20th, 2010 at 7:48 am

pls help me to write a program to fibonacci as output pleae help me


95. Ramesh Says: July 21st, 2010 at 6:30 am

please send the code for this program in java input hours= 12:39,11:44 output = 0:12:39,1:11:44 vice versa.
96. Ramesh Says: July 21st, 2010 at 6:32 am

please send the code for this program in java input hours= 12:39,11:44 output string = 0:12:39,1:11:44? vice versa.
97. Nishant Agrawal Says: July 23rd, 2010 at 8:04 am

* *** ***** ******* *********


98. Arunkumar Says: July 27th, 2010 at 3:32 am

how can improve logic i have more practise but ican not imporve logical mind
99. srinu Says: August 1st, 2010 at 10:49 pm

* *** ***** ******* *********


100.RAJPUROHIT DALPAT Says: August 5th, 2010 at 7:26 am

i want program to find 25 prime no


101.mohit Says: August 9th, 2010 at 1:59 am

its a diamond. 1 121 12321 1234321


102.ravi prakesh bbd (I.t) Says: August 9th, 2010 at 2:00 am

1 212 32123 4321234 543212345 4321234 32123 212 1


103.ayuresh maliya Says: August 9th, 2010 at 2:01 am

please send the code for this program in java input hours= 12:39,11:44 output string = 0:12:39,1:11:44? vice versa.
104.Jagadish Says: August 11th, 2010 at 3:22 am

For the post No 60: Input{a,b,a,b,c,d,a,c,a,b,d,f} output a**** b*** c** d** f* Program ============================== public class Test1 { public static void main(String[] args) { String[] str=new String[]{a,b,a,b,c,d,a,c,a,b,d,f}; String[] str1=new String[str.length]; int flag=0; for(int s=0;s<str1.length;s++) str1[s]=""; for(int i=0;i<str.length;i++) { int count=0; for(int j=0;j<str.length;j++) {

for(int k=0;k<str1.length;k++) { if(str1[k].equals(str[i])) { flag=1; break; } } if(str[i].equals(str[j]) && flag!=1) count++; } if(flag!=1) { System.out.print(str[i]+ " "); for(int c=0;c<count;c++) { System.out.print("*"); } System.out.println(); } str1[i]=str[i]; flag=0; } } }
105.Jagadish Says: August 11th, 2010 at 3:45 am

For the posts 97 & 99 * *** ***** ******* ********* Program ============================= public class Traingle { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub for(int i=1;i<=5;i++) { for(int j=1;j<=i;j++) {

System.out.print("*"); } System.out.println(); } } }
106.Jagadish Says: August 11th, 2010 at 4:03 am

For the post 83 Program ========================================== public class SUM { /** * Sum Of the series 1+2/2*3 + 2+3/3*4 + 3+4/4*5 * The Series will come as 4 + 6 + 8 + .. */ public static void main(String[] args) { // TODO Auto-generated method stub int Total=0; for(int i=1;i + sum); } System.out.println(Sum============>+ Total); } }
107.Jagadish Says: August 11th, 2010 at 9:20 pm

For the post No 86: Program =========================================== public class DigitalSum { /** * Digital Sum Of a number */ public static void main(String[] args) { // TODO Auto-generated method stub int n = 12345; int n1 = n; int sum = 0; int m = 0; do { m = n % 10; n = n / 10; sum += m;

} while(m!=0); System.out.println(Digital Sum Of + n1 + is : +sum); } }


108.alma Says: August 12th, 2010 at 1:59 am

pehlea menu a daso program likhn nu kinai keha a ..sarai program galt nai ena intee.. samjhn d jarorat nhi a. so dont be over smart. m not blame for that bt. e bala guru swamy.d death ho ge yah jinda a..
109.Smita Says: August 13th, 2010 at 8:29 am

import java.io.*; public class Pattern2 { public static void main(String args[]) { System.out.println(This program prints numbers in the right angle manner.THEN REVERSE); int num = Integer.parseInt(args[0]); int counter = 1;int i; for( i = 0; i < num-1; i++) { counter++; for(int j = 1; j < counter; j++) { System.out.print(j + " "); } System.out.println(); } for(int k= 0; k =k; l) { counter++; System.out.print(counter+ ); } System.out.println(); } } } /*OUTPUT 1 12 123 1234

12345 123456 1234567 12345678 123456789 1 2 3 4 5 6 7 8 9 10 123456789 12345678 1234567 123456 12345 1234 123 12 1 THIS IS THE OUTPUT OF ABOVE CODE */
110.yamini Says: August 17th, 2010 at 12:34 am

i wont the program of fibonaccies searies in javascript using function.


111.Siddharth Says: September 14th, 2010 at 4:05 am

WAP to print both if and else statements simultaneously..


112.Siddharth Says: September 14th, 2010 at 5:42 am

TRIANGLE PRINTING:public class Pattern2 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub int i,j,k=1; for(i=1;i<=10;i++){ for (j=1;j<=i;j++){ System.out.print(k); k++; } System.out.println(); } } }
113.senthil Says: September 18th, 2010 at 3:14 am

i want rectangle program


114.senthil Says: September 18th, 2010 at 3:15 am

pls send me coding to my e-mail id


115.senthil Says: September 18th, 2010 at 3:17 am

i want javascript coding like send values to textarea from drop down area..
116.saren Says: September 20th, 2010 at 4:55 pm

how to display all odd numbers in the array greater than even numbers. eg: {3,11,4,9,2,8} ouput: 11,9
117.divya Says: September 22nd, 2010 at 9:30 am

i need a java code for displaying the stars in the below form * ** *** **** *****
118.siddardha Says: September 24th, 2010 at 9:03 pm

String s=apple , String s1=pplea String s2=pleap Please Write a Program any of the 2 Strings are same TCS Interview Question
119.siddardha Says: September 24th, 2010 at 9:07 pm

With out For Loop or While or switch How do you Display 1 to 100 and 100 to 1
120.siddardha Says: September 24th, 2010 at 9:09 pm

int a[]={1,2,3,4,5}; if you iterate array using for loop it will Iterate 5 times How do you write a Program less than 5 times Print all the numbers
121.siddhu Says: September 28th, 2010 at 10:58 pm

String s=apple , String s1=pplea String s2=pleap Please Write a Program all characters of s available in s1 or s2
122.siddhu Says: September 28th, 2010 at 10:59 pm

String s=appalea; Delete character a from the String.with out using StringBuffer and its Methods
123.Sen???? Says: October 2nd, 2010 at 9:47 pm

public class Fibonacci { public static void main(String []args) { int f1=f2=0,f3=1; System.out.println(The Fibo series is ::); System.out.println(f2); for(int i=0;i<10;i++) { System.out.println(f3); f1=f2; f2=f3; f3=f1+f2;

} } }
124.?????z?l???s?????? Says: October 2nd, 2010 at 9:49 pm

Sen????
125.Vijay Says: October 8th, 2010 at 5:37 am

please show me programs in java for 1. To print prime no. from 1 to 100. 2. to check the palindron using while loop 3. for fabonnaci using do-while loop. 4.for type casting 5. to print salary of imploy according to their grade using switch case. 6. to print $$$$ $$$ $$ $
126.saren Says: October 8th, 2010 at 5:43 am

how to find out if the number is flippable for eg. 1961,906,888,


127.osotrop Says: October 22nd, 2010 at 11:27 am

i need a java code for displaying the no in the format 12345 10 9 8 7 6 11 12 13 14 15 20 19 18 17 16


128.siddardha Says: November 6th, 2010 at 9:29 pm

My name is : Robert Bosch I want to display: Bosch Robert Please Try to Implement this Program Dont Copy
129.Farjad Ahmed Babar Says: November 12th, 2010 at 11:47 pm

Ans of Q.66 import java.io.*; public class Print123 { /** * @param args */ public static void main(String[] args)throws Exception { // TODO Auto-generated method stub int i,j; BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

int num=Integer.parseInt(br.readLine()); System.out.println(Enter Number); System.out.println(1); for(i=2;i<=num;i++) { for(j=1;j<=i;j++) { System.out.print(j+" "); } System.out.println(1); } } }
130.Farjad Ahmed Babar Says: November 12th, 2010 at 11:51 pm

Ans of Q.88 /* 1 121 12341 */ import java.io.*; public class Print123 { /** * @param args */ public static void main(String[] args)throws Exception { // TODO Auto-generated method stub int i,j; BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int num=Integer.parseInt(br.readLine()); System.out.println(Enter Number); System.out.println(1); for(i=2;i<=num;i++) { for(j=1;j<=i;j++) { System.out.print(j+" "); } System.out.println(1); } } }
131.Madhavan P Says: November 23rd, 2010 at 12:30 am

Super
132.Alice Says: November 26th, 2010 at 9:05 am

nightFox is dumb and a moron. Probably cant read let alone spell correctly or write a simple program. Seems to have a big ego and likes to criticize falsely and cant appreciate anything cool. Nutcase should be ignored. The program looks good.
133.Alice Says: November 26th, 2010 at 9:31 am

Program that generates fibonacci series works just fine. nightFox is stupid and jealous and should be ignored.
134.anjana Says: December 6th, 2010 at 2:10 am

Thank you very very much,it is very useful to me. first of all thanks to google.
135.suresh Says: December 24th, 2010 at 4:13 am

Ans for Q:23 class a{ psvm(String [] args){ int n=5; for(int i=n;i>=1;i){ for(int j=1;j<=i;j++){ System.out.print(""+j); } System.out.println(""+j); } } }
136.G.Dhinesh Says: December 31st, 2010 at 4:17 am

I need the java program for print the series 0,1,2,3,4,5,6,7,8,9


137.swetha Says: January 1st, 2011 at 8:43 am

i want java program for to print all armstrong numbers between n and m
138.keerthika Says: January 5th, 2011 at 5:29 am

fibonacci using do while in java


139.suresh Says: January 8th, 2011 at 9:05 am

1 Question rajnish : Prime nos for Fibnocci series import java.io.*; class Fibnocci { public static void main(String[] args)throws IOException{ BufferedReader bf=new BufferedReader(new InputStreamReader(System.in)); int n=Integer.parseInt(bf.readLine()); int f1, f2 = 0, f3 = 1; System.out.println(fib(0) = + f2); for (int i = 1; i <= n; i++) { System.out.println("fib(" + i + ") = " + f3);

int j; for(j=2;j<i;j++){ int f=f3%j; if(f==0){ break; } } if(f3==j){ System.out.println("Fibnocci prime nos "+f3);} f1 = f2; f2 = f3; f3 = f1 + f2; } } }
140.shivani Says: January 12th, 2011 at 8:27 am

1 23 456 78 9 how to implement the above program?


141.Abhi Says: January 19th, 2011 at 6:46 am

int n=3,i,j,temp=1; for(i=0;i<=n;i++) { for(j=1;j0;i) { for(int j=1;j<=i;j++) { print(temp); temp++; } print("\n"); }


142.Abhi Says: January 19th, 2011 at 6:48 am

int n=3,temp=1,i,j; for(i=0;i<=n;i++) { for(j=1;j0;i) { for(int j=1;j<=i;j++) { System.out.print(temp); temp++; }

System.out.println(); } System.out.println();
143.Uno ? Cris Says: January 21st, 2011 at 5:01 am

import javax.swing.*; class fib { public static void main(String args[]) { try { int theNum = Integer.parseInt(JOptionPane.showInputDialog(Enter number of sequence: )); fibo(theNum); } catch (NumberFormatException e){ JOptionPane.showMessageDialog(null,That is not an integer. + \nPlease enter an integer value,ERROR, JOptionPane.WARNING_MESSAGE); } System.exit(0); } static void fibo(int num){ int x=0,y=1; for (int i=0;i<num;i++){ System.out.print(x + " "); x=x+y; y=x-y; } System.out.println(); } } // Fibonacci made by ME (^-^)
144.Uno Cris Says: January 21st, 2011 at 5:08 am

just dropping by and saying Goodbye! (^^, )


145.raghu Says: January 26th, 2011 at 7:59 am

i need java code for the following output using arrays 0 12 345 6789
146.raghu Says: January 26th, 2011 at 8:00 am

i requrie code for the following output using arrays 0 12 345

6789 plz help me in this


147.sumedha dhamankar Says: February 7th, 2011 at 11:46 am

need java code for: number to words program.! and ,must say good job!
148.sumedha dhamankar Says: February 7th, 2011 at 11:50 am

plz,help for 1 212 32123 4321234 543212345 4321234 32123 212 1


149.Mangesh Says: February 16th, 2011 at 10:52 am

Answer for Q : 71 class triangle2 { public static void main(String args[]) { for(int i =1 ;i<=5;i++) { for(int j=1;j<=i;j++) { int a = (i + j) % 2; if (a == 0) System.out.print(1 + " " ); else System.out.print(0 +" " ); // System.out.print(a +" " ); } System.out.println(); } } } o/P :: 1 01 101 0101 10101
150.Mangesh Says: February 16th, 2011 at 10:54 am

Answer for Q : 147

class num_in_words{ public static void main(String args[]){ try{ int num = Integer.parseInt(args[0]); int n = num; //used at last time check int reverse=0,remainder; while(num > 0){ remainder = num % 10; reverse = reverse * 10 + remainder; num = num / 10; } String result="; //contains the actual output while(reverse > 0){ remainder = reverse % 10; reverse = reverse / 10; switch(remainder){ case 0 : result = result + Zero ; break; case 1 : result = result + One ; break; case 2 : result = result + Two ; break; case 3 : result = result + Three ; break; case 4 : result = result + Four ; break; case 5 : result = result + Five ; break; case 6 : result = result + Six ; break; case 7 : result = result + Seven ; break; case 8 : result = result + Eight ; break; case 9 : result = result + Nine ; break; default: result=";

} } System.out.println(result); }catch(Exception e){ System.out.println(Invalid Number Format); } } } o/P : 1234 One Two Three Four
151.Mangesh Says: February 16th, 2011 at 11:00 am

Answer for Q : 146 class floyd_tri { public static void main(String args[]) { int k = 0; for(int i =1 ;i<=5;i++) { for(int j=1;j<=i;j++) { System.out.print(k + " "); k++; } System.out.println(); } } } o/P :: 0 12 345 6789 10 11 12 13 14
152.Mangesh Says: February 16th, 2011 at 11:04 am

Answer for Q : 84 class rev_triangle { public static void main(String args[]) { int n=5; for(int i=1;i<=n;i++) { for(int j=1;j0;i){ for(int j=1;j<i;j++){ //System.out.print(j + " "); System.out.print( "* "); } System.out.println(); }

} } o/P : * ** *** **** ***** **** *** ** *


153.Mangesh Says: February 16th, 2011 at 11:10 am

answer for Q : 71 class triangle { public static void main(String args[]) { for(int i =1 ;i<=5;i++) { for(int j=1;j<=i;j++) { System.out.print(i + " "); } System.out.println(); } } } o/P :: 1 22 333 4444 55555
154.Mangesh Says: February 16th, 2011 at 11:10 am

Answer for Q : 71 class triangle_rev { public static void main(String args[]) { for(int i=5 ; i>0; i) { for (int j=1;j<=i;j++) { System.out.print("$ "); } System.out.println(); } } } o/P ::

$$$$$ $$$$ $$$ $$ $


155.Sudeep Says: February 18th, 2011 at 9:50 pm

class PrimeTest { int GivenNo; PrimeTest(int GivenNo) { this.GivenNo=GivenNo; } int findPrime() { while(true) { if(isPrime(GivenNo)) { return GivenNo; } GivenNo++; } } boolean isPrime(int value) { for(int i=2; i<value;i++) { if (value%i==0) { return false; } } return true; } public static void main(String args[]) { PrimeTest pt= new PrimeTest(1001); System.out.println("The next prime no is: " +pt.findPrime()); } }
156.Sudeep Says: February 18th, 2011 at 9:51 pm

the above program is to find the next prime no of a given no


157.Pramod Says: March 4th, 2011 at 11:10 pm

write a java program like 1 24 369 4 8 12 16


158.Pramod Says: March 4th, 2011 at 11:15 pm

write a java program overriding on fruits & its properties


159.kiruba Says: March 7th, 2011 at 6:41 am

int n = 4; System.out.println(1); for (int i = 2; i <= n; i++) { for (int j = 1; j <= i; j++) { System.out.print(i * j); } System.out.println(""); }
160.kiruba Says: March 7th, 2011 at 6:41 am

output: 1 24 369 4 8 12 16
161.Deepak Says: March 7th, 2011 at 9:24 am

I need the tower of Hanoi problem using recursion. Can anyone help it pls.
162.vani Says: March 14th, 2011 at 5:26 am

Hi ! It is a nice collection of good Ideas to sharp our brain.


163.Yessi Says: March 22nd, 2011 at 12:35 pm

i need a code for 543212345 4321234 32123 212 1 help please!


164.jagadeesh Says: April 9th, 2011 at 3:17 am

the above Highest prime no program is proved wrong when we give input as 28 it will give the output as 25 which is not prime.
165.Dibyajyoti Says: April 16th, 2011 at 12:53 am

hey can anyone give me a code for this program sequence: 1 123

5 8 13 21 34 55 89 144 233 these numbers are fibonacci plz help me with this program
166.Dibyajyoti Says: April 16th, 2011 at 12:55 am

by the way, the program sequence should be diamond shaped

Leave a Reply
Top of Form

Name (required) Mail (will not be published) (required) Website

Bottom of Form

Most Popular

Recent Posts

Watch The Last Airbender Online Stream Naruto Shippuden 167 | Naruto Shippuden 167 Planetary Devastation Raw Full Episode Bleach Episode 277 | Bleach 277 Climax! Kyoraku vs. Starrk Full Online Stream True Blood Season 3 Episode 3 It Hurts Me Too Naruto Shippuden 166 Raw Full Episode | Naruto Shippuden 166 Confessions Facebook Emoticon Codes | Facebook Emoticons Facebook Smileys | Smileys for Facebook Chat Watch Crazy on the Outside Online Free Watch Its Complicated Full Video Online Watch Leap Year Free Stream Online

Archives

July 2010 June 2010 April 2010 January 2010 December 2009 November 2009 October 2009 September 2009 August 2009 July 2009 June 2009 May 2009 April 2009 March 2009 February 2009 January 2009 December 2008 November 2008 October 2008 September 2008 August 2008 July 2008 June 2008

Copyright 2008 - 2011 . All rights reserved. Nose Smaller Facebook Emoticons Facebook Smileys Metformin Side Effects Facebook Backgrounds Nose Huggie Edible Arrangements Coupon Edible Arrangements Coupon Code Bed Bath and Beyond Printable Coupon Macys Coupons Unlock iPhone Barnes and Noble Coupon Nose Huggie Peanut Butter Coupons Unlock iPhone 3g Macys Coupons Nose Magic

Potrebbero piacerti anche