Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class FunStrings
- {
- public void FunStrings()
- {
- }//FunStrings
- public int rstl(String str)
- {
- int x = 0;
- int countR=0;
- int countS=0;
- int countT=0;
- int countL=0;
- while(x < str.length()&& str.indexOf("r",x)!= -1)
- {
- countR++;
- x=str.indexOf("r",x)+1;
- }//while for r
- x=0;
- while(x < str.length()&& str.indexOf("s",x)!=-1)
- {
- countS++;
- x=str.indexOf("s",x)+1;
- }//while for s
- x = 0;
- while( x< str.length() && str.indexOf("t",x)!=-1)
- {
- countT++;
- x=str.indexOf("t",x)+1;
- }//while for t
- x = 0;
- while(x < str.length()&& str.indexOf("l",x)!=-1)
- {
- countL++;
- x=str.indexOf("l",x)+1;
- }//while for l
- return countR + countS + countT + countL;
- }
- public boolean evenOdd(int num)
- {
- int rem;
- rem = num % 2;
- if(rem==1)//to determine remainder
- {
- return false;
- }else{
- return true;
- }//It is Even
- }
- public void Song(int lines)
- {
- int lineNum = 100;
- for(int ln=0;ln<lines;ln++)
- {
- System.out.println(lineNum + " lines of code in the program.");
- System.out.println(lineNum + " lines of code...");
- System.out.println("If one line has an error...");
- lineNum--;
- System.out.println(lineNum + " lines of code in the program.");
- System.out.println();
- }//For Loop for line count of song.
- }
- public boolean palindrome(String str)
- {
- str = str.toUpperCase();
- String forward ="", backward="";
- for (int x=0; x < str.length();x++)
- if (!str.substring(x,x+1).equals(" "))
- forward += str.substring(x,x+1);
- for (int x=forward.length()-1; x>=0; x--)
- backward += forward.substring(x,x+1);
- Util.SOPL(forward + " " + backward);
- return backward.equals(forward);
- }//palindrome
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement