-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExercise2.java
More file actions
42 lines (32 loc) · 810 Bytes
/
Exercise2.java
File metadata and controls
42 lines (32 loc) · 810 Bytes
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
package Labbook3;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Scanner;
import javax.swing.JTextField;
public class Exercise2 {
public static void main(String[] args) {
int l =0;
Scanner sc = new Scanner(System.in);
System.out.println("enter number of elements");
int n = sc.nextInt();
String[] Myarray = new String[n];
System.out.println("please enter names to sort");
Scanner sc1 = new Scanner(System.in);
for(int i =0;i<n; i++)
{
Myarray[i]=sc1.nextLine();
//l=Myarray.length;
}
for(int j =0;j<n; j++)
{
int l1 = Myarray.length;
Arrays.sort(Myarray);
if(j<l1/2)
{
Myarray[j]= Myarray[j].toUpperCase();
}}
for(int i=0;i<n;i++) {
System.out.println(Myarray[i]);
}
}
}