Ask a Question | Answer a Question! |

Submitting your question...
ResFinder - Thousands of Practice Papers
/*I don't know why but there is a problem with this code.When I'm entering a number for the value of 'n',and press enter after pressing it, instead of appearing one by one, two input lines appear at once,like:
Enter name 1:
Enter name 2: (Both together,and only one value they accept).
Then, it works properly. I'm forwarding the code, anyone who can help, will be appreciated.*/
import java.util.*;
class BubSortNames
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int i,j,n;
String names[]=new String[100];
String swap="";
System.out.println("Enter the value of 'n':");
n=sc.nextInt();
System.out.println();
for(i=0;i<n;i++)
{
System.out.println("Enter name "+(i+1)+":");
names[i]=new String(sc.nextLine());
}
//Sorting steps.
for(i=0;i<n-1;i++)
{
for(j=0;j<n-1-i;j++)
{
if(names[j].compareTo(names[j+1])>0)
{
swap=names[j];
names[j]=names[j+1];
names[j+1]=swap;
}
}
}
//Displaying the sorted list.
for(i=0;i<n;i++)
System.out.println(names[i]);
}//MAIN.
}//CLASS. |
 |
| asked by Aayush Joshi (aayushjoshi) 7 years ago |
0 |
Other Questions on This Topic
When is the 2026 icse exam? |
 |
| asked by Yogesh (yogesh) 128 days ago |
1 |
+ 3 more questions by yogesh
What is the difference between steam turbines and gas turbines? |
 |
| asked by Yogesh (yogesh) 1 year ago |
1 |
who is jessica's father in merchant of venice? |
 |
| asked by Yogesh (yogesh) 1 year ago |
1 |
What is "how are you" in French? |
 |
| asked by Yogesh (yogesh) 1 year ago |
1 |
https://www.respaper.com/ |
 |
| asked by Sujata Kundu (mumpi_1989) 186 days ago |
1 | + 3 more questions by mumpi_1989
I'm talking about this website! |
 |
| asked by Sujata Kundu (mumpi_1989) 186 days ago |
1 |
There is membership access right... I want to do that... In order to be a member I must pay... How will I do that? Is there any UPI option for payment?? |
 |
| asked by Sujata Kundu (mumpi_1989) 186 days ago |
1 |
Is there any UPI option for payment??? Please help???? |
 |
| asked by Sujata Kundu (mumpi_1989) 186 days ago |
1 |
i'm unable to download papers |
 |
| asked by Tsa (rajpurohit14) 276 days ago |
1 |
Class 9 final question paper |
 |
| asked by Armaan Mandal (arms10) 301 days ago |
0 |
How to contact respaper |
 |
| asked by Insha Naz Fatima (sarahmeh) 323 days ago |
1 | + 2 more questions by sarahmeh
How to contact |
 |
| asked by Insha Naz Fatima (sarahmeh) 323 days ago |
1 |
Hii I have uploaded my school paper yet I have not gotten access to any other paper...why??? Did it happen with someone else too??🙃 |
 |
| asked by Insha Naz Fatima (sarahmeh) 323 days ago |
1 |
8th Icse question papers |
 |
| asked by Aparna Narayan (aparna1974) 1 year ago |
1 |
What's up people? Does anyone I know ever visit this place? If yes please just hit me up with a "hi" I would love to chat haha... Take care everyone :)) |
 |
| asked by Anshika Jaiswal (anshika28) 1 year ago |
4 |
I've got an endsem exam in an hour but all I am doing is reading old threads on res. 🥲 |
 |
| asked by Nisarg Bhavsar (nisarg71) 1 year ago |
3 |
Hlooo..itzz been longgg...ICSE 2018 batch anybody?? |
 |
| asked by Snigdha (silver2002) 1 year ago |
3 |
| | |