-
Notifications
You must be signed in to change notification settings - Fork 0
/
practice.java
38 lines (34 loc) · 1.01 KB
/
practice.java
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
public class practice {
public static void main(String[] args) {
// Practice
// Sum of digits
// int a = 123456789, sum_of_digit = 0;
// while (a>0) {
// int digit = a%10;
// sum_of_digit = sum_of_digit+digit;
// a = a/10;
// }
// // System.out.println("Sum of digits: "+sum_of_digit);
// System.out.println("Total Sum: "+sum_of_digit);
// Pyramid
int row = 5;
for (int i = 0; i<=row; i++){
System.out.println();
for (int j = row-i; j>=1; j--){
System.out.print(" ");
}
for (int k = 0;k <= i; k++){
System.out.print("* ");
}
}
for (int i = row-1; i>=0; i--){
System.out.println();
for (int j = row-i; j>=1; j--){
System.out.print(" ");
}
for (int k = 0;k <= i; k++){
System.out.print("* ");
}
}
}
}