Question: Currently having issues trying to prompt a user for input and assign the input to a variable( either a string or integer). the values are

Currently having issues trying to prompt a user for input and assign the input to a variable( either a string or integer). the values are passed to a method that takes care of edits in a line editor. My problem is that sometimes id like to send over just "function", other times function and lineNum, and other times function, lineNum, and lineNum2.
I want to be able to enter something such as
"function" "linenum" "linenum2"
assign to the variables and the send the values using the makeEdit method, but i also would like it to work if i did something as simple as
"function"
and pressed enter, then executed the makeEdit() method.
ive tried implementing another loop using a boolean and making it so if program detects the user pressing the enter key but that has opened a can of other issues. Any guidance on how to enable a user to enter 1,2, or 3 variables and carry out the makeEdit method would be appreciated. Apologies for the messy code, i plan on trimming the fat off when the functions are working correctly.
Currently having issues trying to prompt a user for input and assign
the input to a variable( either a string or integer). the values
are passed to a method that takes care of edits in a

static int count 1; static String function; static Integer tineNum = null; static Integer tineNum2 null; System.out.println("What function do you wish to execute?"); boolean enter = false; String keystroke; while(enter=false) { function=keyboard.next(); keystroke = keyboard.next(); if(keystroke.equals("")) { enter=true; } lineNum=keyboard.nextInt(); keystroke = keyboard.next(); if(keystroke.equals("")) { enter=true; } lineNum2=keyboard.nextInt(); keystroke - keyboard.next(); if (keystroke.equals("")) { enter=true; } } System.out.println(function + Line Num+ LineNum2+count); makeEdit(function, LineNum, lineNum2, count); I public static void makeEdit(String function, Integer lineNum, Integer lineNum2, int count) { if (function.equalsIgnoreCase("i")&& lineNum==null && lineNum2= null) { executeInsert(count); if(function.equalsignoreCase("I") && lineNum=null && lineNum2==null) { executeInserton(lineNum); 3 if(function.equalsIgnorecase("L") && lineNum==null && lineNum2==null) { listContent(); if(function.equals IgnoreCase("D") && lineNum null && lineNum2=null) I DeleteContent (count); if (function.equalsIgnoreCase("D") && lineNum=null && lineNum2 null) executeDeleteLine(lineNum); if (function.equalsIgnoreCase("0") && lineNum! -null && lineNum2!=null) executeDeletelines(lineNum, lineNum2); 3 if(function.equalsignoreCase("A") && lineNumunull && lineNum2 null)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!