-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLab02_1_630510606.java
51 lines (46 loc) · 1.23 KB
/
Lab02_1_630510606.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
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
Anawin Athawong
630510606
*/
import java.util.*;
public class Lab02_1_630510606{
public static void main(String[] args) {
char ch;
int number;
var input=new Scanner(System.in);
System.out.print("Input character: ");
ch=input.nextLine().charAt(0);
do{
System.out.print("Input Number (between 2 and 10) : ");
number = input.nextInt();
}while(number<2 || number>10);
if(character.toLowerCase(ch)=='a'){
printStarA(number);
}
else if(character.toLowerCase(ch)=='b')printStarB(number);
else{
println("Good bye");
}
}
public static void printStarA(int x){
int row,col;
for(row =x;row>=1;row--){
for(col=1;col<=row;col++){
System.out.print("*");
}
System.out.println();
}
}
public static void printStarB(int x){
int row,col;
for(row =1;row<=x;row++){
for(i=0;i<x-row;i++){
System.out.print(" ");
}
for(col=0;col<row;col++){
System.out.print("*");
}
System.out.println();
}
}
}