Skip to content

Instantly share code, notes, and snippets.

@peter279k peter279k/JPA04.java
Created May 24, 2017

Embed
What would you like to do?
TQC+ JAVA
import java.util.Scanner;
public class JPA03 {
static Scanner keyboard = new Scanner(System.in);
public static void main(String[] args) {
System.out.print("Input a string: ");
String str = keyboard.nextLine();
System.out.println(str + " has " + strR(str) + " As");
System.out.print("Input a string: ");
str = keyboard.nextLine();
System.out.println(str + " has " + strR(str) + " As");
}
public static int strR(String str) {
if(str.equals("")) {
return 0;
}
if(str.substring(0, 1).equals("A")) {
return 1 + strR(str.substring(1));
}
return strR(str.substring(1));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.