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 for loop

1-4 Problem Set: Arithmetic Consider the following statement when responding to questions 1 and 2: Jim develops 5 Java applications a year. Joe develops 10 Java applications a year

a program to find the area under curve y=f(x) between x=a and x=b,integrate y=f(x) between the limits of a and b

Writing a report

what will be the logic? in C program #include float start_point, /* GLOBAL VARIABLES */ end_point, total_area; int numtraps; m

pebble merchant

Develop a simple polling (voting) web application according to the following specifications: 1. Initially a page should be presented to the user where he can enter his/her

wap to find all the prime palindromic numbers

I need some Unique Idea About my final Year Project . It could be a Website or an Android application. I want to create Something very unique which in some sense benefits a society

program t ofind area under the curve y=f(x) between x=a and x=b integrate y=f(x) between the limits a and b