I have a driver and server and i can't figure out how to print the # of characters for each input they enter
I need help on figuring out how to alphabetize the user inputs
Someone plz help me
thanks
THIS IS SERVER.
import java.util.Scann er;
public class AlphabetizePara puzha {
static Scanner reader = new Scanner (System.in);
private String [] names = new String [4];//the array that holds 4 names
private int option;//the user option
private int count;//the counter
private String name;//close name
public AlphabetizePara puzha(){
while(true){
menu();
selection();
}//close whlie
}//close main
public int menu()
{
while(true){
String menu = "\n\4ENTER GAME\4\n1)Print \n2)Enter 4 Strings"
+ "\n3)Quit" + "\nMake a selection: ";
try{
System.out.prin t(menu);
option = reader.nextInt( );
if(option >= 1 && option <= 3){
reader.nextLine ();//CONSUME EXTRA CHARACTER
break;
}else{
System.out.prin t("\nEnter a 1 or 2:\n");
reader.nextLine ();
}//close if
}catch(Exceptio n e){
System.out.prin t("\nEnter a number answer:\n");
reader.nextLine ();
}//exception
}//close whlie
return option;
}//close menu
public void setChoice(int answer)
{
option = answer;
}//close setChoice
public int getChoice()
{
return option;
}//close getChoice
public int selection()
{
if(getChoice() == 3){
quit();
}else if(getChoice() == 2){
for(int i = 0; count < names.length; i++){
System.out.prin t("\nEnter Your name: ");
name = reader.nextLine ();
names[count] = name;
count++;
}//close for
}else{
print();
}//close if
return option;
}//close getRun
public void quit()
{
System.exit(99) ;
}//close quit
public void print()
{
System.out.prin t("\nCOLOUM #2:\n");
for(int i = 0; i < count; i++){
int l = name.length();
System.out.prin t("# of Characters are " + l + "\n");
}//close for
}//close getPrint
}//AlphabetizePara puzha
I need help on figuring out how to alphabetize the user inputs
Someone plz help me
thanks
THIS IS SERVER.
import java.util.Scann er;
public class AlphabetizePara puzha {
static Scanner reader = new Scanner (System.in);
private String [] names = new String [4];//the array that holds 4 names
private int option;//the user option
private int count;//the counter
private String name;//close name
public AlphabetizePara puzha(){
while(true){
menu();
selection();
}//close whlie
}//close main
public int menu()
{
while(true){
String menu = "\n\4ENTER GAME\4\n1)Print \n2)Enter 4 Strings"
+ "\n3)Quit" + "\nMake a selection: ";
try{
System.out.prin t(menu);
option = reader.nextInt( );
if(option >= 1 && option <= 3){
reader.nextLine ();//CONSUME EXTRA CHARACTER
break;
}else{
System.out.prin t("\nEnter a 1 or 2:\n");
reader.nextLine ();
}//close if
}catch(Exceptio n e){
System.out.prin t("\nEnter a number answer:\n");
reader.nextLine ();
}//exception
}//close whlie
return option;
}//close menu
public void setChoice(int answer)
{
option = answer;
}//close setChoice
public int getChoice()
{
return option;
}//close getChoice
public int selection()
{
if(getChoice() == 3){
quit();
}else if(getChoice() == 2){
for(int i = 0; count < names.length; i++){
System.out.prin t("\nEnter Your name: ");
name = reader.nextLine ();
names[count] = name;
count++;
}//close for
}else{
print();
}//close if
return option;
}//close getRun
public void quit()
{
System.exit(99) ;
}//close quit
public void print()
{
System.out.prin t("\nCOLOUM #2:\n");
for(int i = 0; i < count; i++){
int l = name.length();
System.out.prin t("# of Characters are " + l + "\n");
}//close for
}//close getPrint
}//AlphabetizePara puzha
Comment