padovan string, C/C++ Programming

write a javaprogram to solve padovan string using java?

program in java

// aakash , suraj , prem sasi kumar kamaraj college
program 1 :

package test.padovanstring;

public class PadovanString {
    public int stringOccurrences(int n, String str){
    if(n >= 40)
    return -1;
    return -1;
    String res=pad(n);
    return(res.length() - res.replaceAll(str,"").length())/(str.length());
public String pad(int n){
    if(n == 0) return "X";
    if(n == 1) return "Y";
    if(n == 2) return "Z";
    else return pad(n-2) + pad(n-3);
    public static void main(String []args)
        PadovanString p = new PadovanString();




Program set 2 :

import java.util.Scanner;

import java.util.ArrayList;


public class PadovanSeries


    public static void main(String[] arg)


        Scanner read = new Scanner(;

        System.out.println("Enter starting no. : ");

        int start = read.nextInt();

        System.out.println("Enter ending no. : ");

        int end = read.nextInt();

        int[] ans = getSeries(start, end);

        System.out.println("Padovan series : ");

        for (int a : ans)

            System.out.print(a + " ");



    public static int[] getSeries(int s, int e)


        ArrayList list = new ArrayList();

        int i, j = 0;

        for (i = s; i <= e; i++, j++)


        int[] ans = new int[j];

        for (i = 0; i < j; i++)

            ans[i] = list.get(i);

        return ans;



    public static int getPadovan(int p)


        if (p == 0 || p == 1 || p == 2)

            return 1;

        return (getPadovan(p - 2) + getPadovan(p - 3));







Posted Date: 9/3/2012 3:10:08 AM | Location : United States

Related Discussions:- padovan string, Assignment Help, Ask Question on padovan string, Get Answer, Expert's Help, padovan string Discussions

Write discussion on padovan string
Your posts are moderated
Related Questions
Project Description: 1) Develop banking software 2) Payment Gateway System There is some other system available for development. I'm willing to show long-term opportunity

if one won't explicitly call the destructor of a local; then how does he handle the above situation?

Insert values in queue - C++ program: Write a program to insert values in queue. int main()   {         int k;     Queue timeLine;     cout     for(

Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec

A: No. Syntax wise it is permitted. But then the function is no longer Inline. Since the compiler will never know how deep the recursion is at compilation time.

Question: (a) Describe what are dynamic pointers. Show their memory representations diagrammatically. (b) Write short notes about pointers in arrays, paying attention on

The probabilistic Hough transform uses random sampling instead of an accumulator array. In this approach the number of random samples r, is not specified in the OpenCV call, but is