-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathC02_ProjeOdevi.java
More file actions
44 lines (35 loc) · 1.1 KB
/
C02_ProjeOdevi.java
File metadata and controls
44 lines (35 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package day01_gitupProjeOdevi;
import java.util.Scanner;
public class C02_ProjeOdevi {
public static void main(String[] args) {
/******
* Tugba Hanim ***** Pozitif bir int num verildiğinde, return edildiği zaman num
* tamkare ise true veren değilse false veren bir fonksiyon yazın.
*
* Not: sqrt gibi fonksiyonları kullanmayın.
*
* Example 1: Input: 16 Output: true Not: bu sayı tamkare çünkü 4*4 = 16
*
* Example 2: Input: 25 Output: true Note: bu sayı tamkare çünkü 5*5=25
*
*
* Example 3: Input: 14 Output: false
*/
Scanner scan = new Scanner(System.in);
System.out.println("Lutfen bir pozitif sayi giriniz");
int sayi = scan.nextInt();
if (sayi <= 0) {
System.out.println("Yalnis sayi girdiniz pozitif bir sayi girin lutfen");
}
for (int i = 1; i <= sayi; i++) {
if (sayi==i*i) {
System.out.println(true);
System.out.println("bu sayi tam kare cunku " + i + "*" + i + "=" + sayi);
break;
} else if(sayi==i){
System.out.println(false);
break;
}
}
}
}