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
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("\t1. To update the Students name.");
System.out.println("\t5. 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;
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started