Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class AssignmenQuestion4{
- static int bunnyEarCounter=0;
- public static void main(String[] args){
- Scanner sc=new Scanner(System.in);
- int x=sc.nextInt();
- EvenEars(x);
- System.out.print("Total Ears="+bunnyEarCounter);
- }
- public static void EvenEars(int a){
- if(a>0){
- if(a%2==0){
- bunnyEarCounter+=3;
- }
- else{
- bunnyEarCounter+=2;
- }
- EvenEars(a-1);
- }
- }
- }
Add Comment
Please, Sign In to add comment