-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEvent.java
More file actions
56 lines (51 loc) · 1.62 KB
/
Event.java
File metadata and controls
56 lines (51 loc) · 1.62 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
45
46
47
48
49
50
51
52
53
54
55
56
// Program: Vertical Display of Team Names
// Topic: String Handling and Arrays
// Description: Reads multiple team names and prints them vertically character by character,
// aligning columns based on the longest word length. Demonstrates use of nested loops,
// string length comparison, and formatted output for text alignment.
package stringhandling;
import java.util.*;
/**
*
* @author Samim
*/
public class Event {
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int maxlength=0;
int n;
System.out.println("Enter The Number Of Teams (1<N<10) :");
n=sc.nextInt();
String ar[]=new String [n];
if(n>1 && n<9){
System.out.println("Enter The Teams :");
for(int i=0;i<n;i++){
ar[i]=sc.next();
}
}
else{
System.out.println("Input Not in Range :");
System.exit(0);
}
for(String teams:ar){
if(teams.length()>maxlength){
maxlength=teams.length();
}
}
for(int i=0;i<maxlength;i++){
for(int j=0;j<ar.length;j++){
if(i<ar[j].length()){
System.out.print(ar[j].charAt(i));
}
else
{
System.out.print(" ");
}
if(j<ar.length-1){
System.out.print(" ");
}
}
System.out.println();
}
}
}