Example__1

PHOTO EMBED

Mon May 29 2023 15:47:49 GMT+0000 (Coordinated Universal Time)

Saved by @Mohamedshariif #java

import java.util.Scanner;

public class Exercise {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		System.out.println("How many times do you want to say (I LOVE YOU):");
		int number = scanner.nextInt();
		
		
		Love(number);
	
	}
	static void Love(int n){
//base case
		if(n>0) {
			System.out.println("I LOVE YOU " +n+ " times.");
			n--;
			Love(n);
		}
		else {
			System.out.println("have nice day my Love");
		}
	}
	
}
//output:
How many times do you want to say (I LOVE YOU):
10
I LOVE YOU 10 times.
I LOVE YOU 9 times.
I LOVE YOU 8 times.
I LOVE YOU 7 times.
I LOVE YOU 6 times.
I LOVE YOU 5 times.
I LOVE YOU 4 times.
I LOVE YOU 3 times.
I LOVE YOU 2 times.
I LOVE YOU 1 times.
have nice day my Love
content_copyCOPY