-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnametelephone.java
47 lines (37 loc) · 1.12 KB
/
nametelephone.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
import java.util.*;
public class nametelephone
{
public static void main(){
Scanner sc=new Scanner(System.in);
int i,j,k=0,min,minposition=0;
String m[]=new String[3];
int n[]=new int[3];
for( i=0;i<=2;i++){
System.out.println("enter the name and telephone");
m[i] = sc.next();
n[i]=sc.nextInt();
}
String str=m[0];
String str1=" ";
int tmp=0;
for( i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
if(m[j].compareTo(m[j+1])>0)
{
str1=m[j];
m[j]=m[j+1];
m[j+1]=str1;
tmp=n[j];
n[j]=n[j+1];
n[j+1]=tmp;
}
}
}
System.out.println("number with marks");
for(i=0;i<=2;i++){
System.out.println(n[i]+m[i]);
}
}
}