padovan string, Computer Engineering

how to write this program,what are the declaration and function are needed in 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 2:14:23 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
Can matchcode object contain Ids with different update types? Yes.

Explain the Structure of a C Program? Each C program consists of one or more functions one of the which must be main(). A function name is forever followed by a pair of parenth

explain djnz instruction of intel 8051 microcontroler

What is schedulers?  A process migrates between the various scheduling queues throughout its life time. The OS must select processes from these queues in some fashion. This sel

Give the format of Ethernet frame and explain the semantics of each field. An Ethernet frame starts with headers which have three fields. The 64-bit preamble, which precedes th

Cost Involved in Inter-Processor Communication Because data is assigned to too many processors in a parallel computer whilst executing a parallel algorithm processors may be ne

Assignment 4: Handwritten Bangla Numeral Recognition using Multilayer Feed Forward Neural Network. In this assignment, you will design a multi layer feed forward neural network

An object model for university system Establishing relationship among various classes in the system is the primary activity. Here, we have a simple model of a University System

What is CMP instruction Comparison instruction (CMP) is a subtraction that changes only the flag bits; destination operand never changes. A comparison is useful for checking th

Q. Show the categories of Web browser? The two basic categories of Web browser are: • Text-only browsers: A text-only browser like Lynx allows you to view Web pag