code, JAVA Programming

pls telme source code for Padovan String
Posted Date: 9/1/2012 2:34:49 AM | Location : United States





package test.padovanstring;

public class PadovanString {
public int stringOccurrences(int n, String str){

if(n >= 40)
return -1;
if(str.replaceAll("X|Y|Z","").length()>0)
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();
System.out.println(p.stringOccurrences(21,"YZ"));
}
}
Posted by gourav | Posted Date: 9/7/2012 11:48:55 AM


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

Write discussion on code
Your posts are moderated
Related Questions
write a program in java using array and scanner class to generate padovan series

Write code in JavaScript to display the odd numbers among 20 to 100 using FOR statement? Note: No required to write whole HTML program. Just JavaScript code of require elemen

Design and simulate the bilbo board which should include three configurable bilbos and some application logic to verify tester operation. the system will be designed using proteus

how to write a java program for pebble merchant

Since there are only a finite number of bonds available in the market. There will always be "holes" to fill in when defining a yield curve in continuous time. A common approach is

Can you help? this assignment I will need to build a very straightforward and fully functional machine learning classifier with the K-Nearest Neighbor (KNN) algorithm. The KNN mode

Elaborate Vector or Object oriented graphics along with at least one example. Object Oriented Graphics are the graphics that are commonly oriented towards the objects and have

GUI-Based Application Objectives:   (1)   Learning how to write a GUI-based application in Java. (2) Learning how to write an event driven application program in Java.

What are the conditions for exiting the while loop?

Project Description: I want to create similar site: fifacointrader I want similar site like fifacointrader.com Skills required are HTML, Java, PHP, Website Design, Wordpre