Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have an array of string and I wanted to know how could I write a code where th

ID: 3601274 • Letter: I

Question

I have an array of string and I wanted to know how could I write a code where the user can edit, update, and save the strings in Java?

Here is the code so far. The names are appearing as Ljava.lang.String;@55f96302 [Ljava.lang.String;@3d4eac69 as well.

import java.util.Scanner;

public class ffff

{

public static void main(String[] args)

{

menu CMenu = new menu();

CMenu.mainmenu();

}

}

/*New Class*/

public class menu

{

public double mainmenu()

{

int MenuSelection;

Scanner keyboard = new Scanner(System.in);

student select = new student();

System.out.print("Welcome to Krusty Clown College! ");

System.out.println("-------------------------------- ");

do

{

System.out.print("Please select any of the following below: ");

System.out.print("------------------------------------------ ");

System.out.println(" 1. To update the Students name.");

System.out.println(" 5. To quit.");

MenuSelection = keyboard.nextInt();

if (MenuSelection > 5 || MenuSelection < 1 )

{

System.out.print(" Invalid response!! ");

}

} while(MenuSelection < 1 || MenuSelection > 5);

switch (MenuSelection)

{

case 1: student.main();

break;

case 5:

System.out.print(" Goodbye and have the last laugh.");

break;

}

return 0;

}

}

/*New Class*/

public class student

{

public static double main()

{

int[] SID = { 7675309, 7778311, 227666, 367394};

String[] SFName = {"ted", "james"};

String[] SLName = {"smith", "jones"};

String[] SelectFName = SFName;

String[] SelectLName = SLName;

menu StudentBack = new menu();

int StudentSelect;   

Scanner keyboard = new Scanner(System.in);  

  

do

{

System.out.print(" Please select the student you would like to edit ");

System.out.print("------------------------------------------------ ");

System.out.println(" 1." + SID[0] + ": "+SFName[0] +" "+SLName[0]);

System.out.println("2." + SID[1] + ": "+SFName[1] +" "+SLName[1]);

System.out.println("3." + SID[2] + ": "+SFName[2]+" "+SLName[2]);

System.out.println("4." + SID[3] + ": "+SFName[3]+" "+SLName[3]);

System.out.println("5.To go back to the main menu.");

StudentSelect = keyboard.nextInt();

if (StudentSelect > 5 || StudentSelect < 1 )

{

System.out.print(" Invalid response!! ");

}

if (StudentSelect == 5)

{

StudentBack.mainmenu();

}

} while(StudentSelect < 1 || StudentSelect > 5);

switch (StudentSelect)

{

case 1:

SelectFName = SFName;

SelectLName = SLName;

Sedit(SelectFName,SelectLName) ;

break;

}

return 0;

}

public static int Sedit(String[] selectFName, String[] selectLName)

{

Scanner keyboard = new Scanner(System.in);  

int EditNameMenu;

String EditFName;

String EditLName;

String EditNames;

do

{

System.out.println("You selected: " + (selectFName) + " " + (selectLName) );

System.out.print("------------------------------------- ");

System.out.print("Edit the first name of the student. ");

EditFName = keyboard.next();

System.out.print((selectFName));

  

System.out.println("5. To go back to the previous menu.");

menu EditNameBack = new menu();

EditNameMenu = keyboard.nextInt();

if (EditNameMenu == 5)

{

main();

}

if (EditNameMenu > 2 || EditNameMenu < 1 )

{

System.out.print(" Invalid response!! ");

}

} while (EditNameMenu < 1 || EditNameMenu > 2);

  

switch (EditNameMenu)

{

case 1:;

break;

case 5:

System.out.print(" Goodbye and have the last laugh.");

break;

}

return 0 ;

}

public static int getSedit(String selectFName, String SelectLName)

{

System.out.print(" Goodbye and have the last laugh.");

return 0;

}

}

Explanation / Answer

You are printing a variable which is a string array so you are getting the output as mentioned in the question. You need to print actual member of the array.

Please find below the updated working code:-

import java.util.Scanner;

public class ffff

{

public static void main(String[] args)

{

menu CMenu = new menu();

CMenu.mainmenu();

}

private static class menu

{

public double mainmenu()

{

int MenuSelection;

Scanner keyboard = new Scanner(System.in);

student select = new student();

System.out.print("Welcome to Krusty Clown College! ");

System.out.println("-------------------------------- ");

do

{

System.out.print("Please select any of the following below: ");

System.out.print("------------------------------------------ ");

System.out.println(" 1. To update the Students name.");

System.out.println(" 5. To quit.");

MenuSelection = keyboard.nextInt();

if (MenuSelection > 5 || MenuSelection < 1 )

{

System.out.print(" Invalid response!! ");

}

} while(MenuSelection < 1 || MenuSelection > 5);

switch (MenuSelection)

{

case 1: student.main();

break;

case 5:

System.out.print(" Goodbye and have the last laugh.");

break;

}

return 0;   

}

}

private static class student

{

static int[] SID = { 7675309, 7778311, 227666, 367394};

static String[] SFName = {"ted", "james","donald","charlie"};

static String[] SLName = {"smith", "jones","trump","lee"};

static String[] SelectFName = SFName;

static String[] SelectLName = SLName;

public static double main()

{

menu StudentBack = new menu();

int StudentSelect;   

Scanner keyboard = new Scanner(System.in);  

  

do

{

System.out.print(" Please select the student you would like to edit ");

System.out.print("------------------------------------------------ ");

System.out.println(" 1." + SID[0] + ": "+SFName[0] +" "+SLName[0]);

System.out.println("2." + SID[1] + ": "+SFName[1] +" "+SLName[1]);

System.out.println("3." + SID[2] + ": "+SFName[2]+" "+SLName[2]);

System.out.println("4." + SID[3] + ": "+SFName[3]+" "+SLName[3]);

System.out.println("5.To go back to the main menu.");

StudentSelect = keyboard.nextInt();

if (StudentSelect > 5 || StudentSelect < 1 )

{

System.out.print(" Invalid response!! ");

}

if (StudentSelect == 5)

{

StudentBack.mainmenu();

}

} while(StudentSelect < 1 || StudentSelect > 5);

switch (StudentSelect)

{   

case 1:

case 2:

case 3:

case 4:

SelectFName = SFName;

SelectLName = SLName;

Sedit(SelectFName,SelectLName,StudentSelect-1) ;

break;

}

return 0;

}

public static int Sedit(String[] selectFName, String[] selectLName,int StudentSelect)

{

Scanner keyboard = new Scanner(System.in);  

int EditNameMenu;

String EditFName;

String EditLName;

String EditNames;

do

{

System.out.println("You selected: " + (selectFName[StudentSelect]) + " " + (selectLName[StudentSelect]) );

System.out.print("------------------------------------- ");

System.out.print("Edit the first name of the student. ");

EditFName = keyboard.next();

selectFName[StudentSelect]=EditFName;

System.out.print((selectFName[StudentSelect]));

  

System.out.println("5. To go back to the previous menu.");

menu EditNameBack = new menu();

EditNameMenu = keyboard.nextInt();

if (EditNameMenu == 5)

{

main();

break;

}

if (EditNameMenu > 5 || EditNameMenu < 1 )

{

System.out.print(" Invalid response!! ");

}

} while (EditNameMenu < 1 || EditNameMenu > 5);

  

switch (EditNameMenu)

{

case 1:;

break;

case 5:

System.out.print(" Goodbye and have the last laugh.");

break;

}

return 0 ;

}

public static int getSedit(String selectFName, String SelectLName)

{

System.out.print(" Goodbye and have the last laugh.");

return 0;

}

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote