-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuadraticSolver
More file actions
606 lines (603 loc) · 29 KB
/
QuadraticSolver
File metadata and controls
606 lines (603 loc) · 29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
/*******************************************************************************
* Quadratic_Solver.java
*
* Description: The source file of "Everything Quadratics" which is a program to
* solve and manipulate user-inputted quadratic equations.
*
* By Stefan Kussmaul and Matthew Mcmullin
*******************************************************************************/
import java.io.Closeable; /* for closing files */
import java.io.*;
import java.util.Vector; /* for using vectors */
import java.util.Scanner; /* for console input */
class Quadratic_Solver
{
public static void main(String[] args) {
/* set default values */
boolean calc_vertex = true, calc_yintercept = true, print_table = true,
calc_sumproduct = true, factor_equation = true, equation_loaded,
has_solution = false, allow_complex = true;
/* equation_loaded tells if there is currently an equation entered */
int[] table_boundaries = {-10, 10};
double[] equation = new double [3];
double[] vertex = new double [2];
double[] solution = new double [2];
System.out.print("Plain+Simple Quadratic Solver");
System.out.print("\n Press enter\n");
new Scanner(System.in).nextLine(); /* waits for user to hit enter */
int menu_input;
do {
/* load settings from file */
LoadSettings(calc_vertex, calc_yintercept, print_table, calc_sumproduct,
factor_equation, table_boundaries, allow_complex);
/* attempt to load last equation used from "quadratics_current" file */
equation_loaded = GetEquationFromFile("quadratics_current", 1, true, equation, false);
if(equation_loaded) {
System.out.print("Current equation loaded: ");
PrintEquation(equation[0], equation[1], equation[2]);
System.out.print("\n\n");
}
else
System.out.print("No equation loaded\n\n");
int line_counter = 1;
System.out.print("\nAvailable Functions\n");
System.out.print("---------------------------------\n");
if(equation_loaded) {
/* only display if an equation is loaded and ready for use */
System.out.print(line_counter + ". Solve Equation\n");
line_counter++;
System.out.print(line_counter + ". Factor Equation\n"); /// I'm sure you can figure out a more efficient way to do this
line_counter++;
System.out.print(line_counter + ". Analyze Equation\n");
line_counter++;
}
System.out.print(line_counter + ". Enter New Equation\n");
line_counter++;
System.out.print(line_counter + ". Choose From Equation List\n");
line_counter++;
System.out.print(line_counter + ". Options\n");
line_counter++;
System.out.print(line_counter + ". Help\n");
line_counter++;
System.out.print(line_counter + ". Quit\n");
line_counter++;
System.out.print("---------------------------------\n");
System.out.print("Enter choice: ");
Scanner input = new Scanner(System.in);
menu_input = input.nextInt();;
if(equation_loaded) {
/* menu when equation IS loaded */
do {
switch (menu_input) {
case 1:
CalculateRoots(equation, solution, has_solution, true, allow_complex);
break;
case 2:
System.out.print(Factor(equation, solution, has_solution, allow_complex));
break;
case 3:
Display(equation, vertex, solution, has_solution, calc_vertex,
calc_yintercept, print_table, calc_sumproduct, factor_equation,
table_boundaries, allow_complex);
break;
case 4:
InputEquation(equation);
break;
case 5:
DisplayEquations(equation);
break;
case 6:
Options(calc_vertex, calc_yintercept, print_table, calc_sumproduct,
factor_equation, table_boundaries, allow_complex);
break;
case 7:
System.out.print("This function has not been created yet\n\n");
break;
case 8:
//exit(0); /// does this require us finding a java equivalent?
break;
default:
System.out.print("Please enter a valid number between 1 and 8\n\n");
break;
}
}while (menu_input < 1 || menu_input > 8);
}
else {
/* menu when equation IS NOT loaded */ /// could this be refactored?
do{
switch(menu_input) {
case 1:
InputEquation(equation);
break;
case 2:
DisplayEquations(equation);
break;
case 3:
Options(calc_vertex, calc_yintercept, print_table, calc_sumproduct,
factor_equation, table_boundaries, allow_complex);
break;
case 4:
System.out.print("This function has not been created yet\n\n");
break;
case 5:
// exit(0);
break;
default:
System.out.print("Please enter a valid number between 1 and 5\n\n");
break;
}
}while(menu_input < 1 || menu_input > 5);
}
System.out.print("\n\nHit enter to return to menu "); /// want this to make the program wait until user hits enter
new Scanner(System.in).nextLine(); /* waits for user to hit enter */
}
while (menu_input != 3);
}
public static void InputEquation(double equation[]) {
String choice;
System.out.print("Equation will be entered in the form ax^2 + bx + c = 0\n\n");
for (int i = 0; i < 3; i++) {
/* 97 is the ascii character a, so this goes from a to c in the loop */
System.out.print("Enter " + (char)(i + 97) + " >> term: ");
equation[i] = Double.parseDouble(GetConsoleInput());
}
try {
FileWriter file = new FileWriter("quadratics_current");
BufferedWriter current_equation = new BufferedWriter(file);
/* write current equation to file in proper string format (a,b,c) */
current_equation.write(EquationToString(equation[0], equation[1], equation[2]));
current_equation.close();
} catch (IOException e) {
System.out.println("Error: could not write to file.\n");
}
System.out.print("Save equation? (y/n) ");
Scanner input = new Scanner(System.in);
choice = GetConsoleInput();
if(choice == "y")
SaveEquation(equation[0], equation[1], equation[2]);
}
public static void CalculateRoots(double equation[], double solution[],
boolean has_solution, boolean print, boolean allow_complex) {
has_solution = true; /* set to true by default - will be checked later */
/* b^2 - 4ac */
double discriminant = Math.pow(equation[1], 2) - (4 * equation[0] * equation[2]);
if (discriminant < 0) { /* if discriminant is less than zero, no real solutions */
has_solution = false;
}
if(has_solution) { /* equation has real solutions */
/* -b + root b^2 - 4ac / 2a */
solution[0] = (-equation[1] + Math.sqrt(discriminant)) / (2 * equation[0]);
/* -b - root b^2 - 4ac / 2a */
solution[1] = (-equation[1] - Math.sqrt(discriminant)) / (2 * equation[0]);
} else { /* no real solutions */
solution[0] = (-equation[1] - Math.sqrt(-discriminant)) / (2 * equation[0]);
solution[1] = (-equation[1] - Math.sqrt(discriminant)) / (2 * equation[0]);
}
if(print) {
if(has_solution)
System.out.print("Root(s): (0," + solution[0] + ")");
if (solution[0] != solution[1]) { /* two solutions */
System.out.print(" and (0," + solution[1] + ")");
}
System.out.print("\n");
if (!has_solution && !allow_complex) { /* no real solutions and complex not allowed */
System.out.print("Equation has no solutions\n");
} else if(!has_solution && allow_complex) { /* complex solution */
System.out.print("Root(s): (0," + solution[1] + "i)");
if(solution[0] != solution[1])
System.out.println(" and (0," + solution[1] + "i)");
}
}
}
public static void CalculateVertex(double equation[], double vertex[]) {
vertex[0] = (-equation[1]) / (2 * equation[0]);
vertex[1] = PlugIn(vertex[0], equation);
}
public static double CalculateYIntercept(double equation[]) {
return PlugIn(0, equation);
}
public static void Options(boolean calc_vertex, boolean calc_yintercept, boolean print_table,
boolean calc_sumproduct, boolean factor_equation,
int table_boundaries[], boolean allow_complex) {
LoadSettings(calc_vertex, calc_yintercept, print_table, calc_sumproduct,
factor_equation, table_boundaries, allow_complex);
DisplayOptions(calc_vertex, calc_yintercept, print_table, calc_sumproduct,
factor_equation, table_boundaries, allow_complex);
System.out.print("Enter number of choice you would like to change: ");
int choice = 0;
do{
choice = Integer.parseInt(GetConsoleInput());
switch (choice) {
case 1:
calc_vertex = !calc_vertex;
System.out.print("Calculate Vertex set to \"" + booleanToString(calc_vertex) + " \"\n");
break;
case 2:
calc_yintercept = ! calc_yintercept;
System.out.print("Calculate y-Intercept set to \"" + booleanToString(
calc_yintercept) + " \"\n");
break;
case 3:
print_table = !print_table;
System.out.print("Print Table set to \"" + booleanToString(print_table) + " \"\n");
break;
case 4:
calc_sumproduct = !calc_sumproduct;
System.out.print("Calculate Sum and Product set to \"" + booleanToString(
calc_sumproduct) + " \"\n");
break;
case 5:
factor_equation = !factor_equation;
System.out.print("Factor Equation set to \"" + booleanToString(factor_equation) +
" \"\n");
break;
case 6:
System.out.print("Enter lower bound: ");
table_boundaries[0] = Integer.parseInt(GetConsoleInput());
System.out.print("Enter upper bound: ");
table_boundaries[1] = Integer.parseInt(GetConsoleInput());
System.out.print("New bounds set to (" + table_boundaries[0] + "," +
table_boundaries[1] + ")\n");
break;
case 7:
break; /* this does nothing so that the thing after the switch case takes it but it doesn't activate the default case */
case 8:
allow_complex = !allow_complex;
System.out.print("Allow Complex Solutions set to \"" + booleanToString(allow_complex) + "\"\n");
default:
System.out.print("\nPlease enter a choice between 1 and 7:\n");
break;
}
} while (choice < 1 || choice > 7);
String string_settings = "" + booleanToChar(calc_vertex) + booleanToChar(
calc_yintercept) + booleanToChar(print_table) + booleanToChar(
calc_sumproduct) + booleanToChar(factor_equation) + Integer.toString(
table_boundaries[0]) + ',' + Integer.toString(table_boundaries[1]);
try{
FileWriter file = new FileWriter("quadratics_settings");
BufferedWriter settings_file = new BufferedWriter(file);
settings_file.write(string_settings);
settings_file.close();
} catch(IOException e) {
System.out.println("Error encountered writing file.\n");
}
}
public static void Table(double equation[], boolean print_table, int table_boundaries[]) { /// needs to be formatted
System.out.print(" x f(x)\n");
for (int i = table_boundaries[0]; i <= table_boundaries[1]; i++) {
System.out.print(" " + i + " " + PlugIn(i, equation) + "\n");
}
}
public static void Display(double equation[], double vertex[], double solution[],
boolean has_solution, boolean calc_vertex, boolean calc_yintercept, boolean print_table,
boolean calc_sumproduct, boolean factor_equation, int table_boundaries[], boolean allow_complex) {
System.out.print("\n\n");
if (calc_vertex) {
CalculateVertex(equation, vertex);
}
if (calc_yintercept) {
/// ok, it's calculated - now it needs to be stored!
CalculateYIntercept(equation);
}
System.out.print("Equation: ");
PrintEquation(equation[0], equation[1], equation[2]);
CalculateRoots(equation, solution, has_solution, true, allow_complex);
if (calc_sumproduct) {
System.out.print("Sum of roots = " + solution[0] + solution[1] +
"\n");
System.out.print("Product of roots = ");
if(has_solution)
System.out.print(solution[0] * solution[1] + "\n");
else if(!has_solution && allow_complex)
System.out.print(-1 * solution[0] * solution[1] + "\n");
}
if (factor_equation) {
String f = Factor(equation, solution, has_solution, allow_complex);
System.out.print(f);
}
if (calc_vertex) {
System.out.print("Vertex: (" + vertex[0] + "," + vertex[1] + ")\n");
}
if (calc_yintercept) {
System.out.print("y-Intercept: (0," + equation[1] + ")\n");
}
if (print_table) {
Table(equation, print_table, table_boundaries);
}
}
public static String Factor(double equation[], double solution[], boolean has_solution,
boolean allow_complex) { /// why does this return a string?
/// why not just void, and print it directly?
/* plug in 1 */
double equation_factor = PlugIn(1, equation) / ((1 - solution[0]) * (1 - solution[1]));
if(!has_solution && allow_complex)
equation_factor = equation_factor * -1;
if (solution[0] != solution[1]) {
return Double.toString(equation_factor) +
"(x" + GetSign(solution[0]) + Double.toString(solution[0]) + ")" +
"(x" + GetSign(solution[1]) + Double.toString(solution[1]) + ")";
} else {
return Double.toString(equation_factor) +
"(x" + GetSign(solution[0]) + Double.toString(solution[0]) + ")^2";
}
}
public static String booleanToString(boolean boolean_to_convert) {
if (boolean_to_convert == true) {return "TRUE";}
else {return "FALSE";}
}
public static void LoadSettings(boolean calc_vertex,
boolean calc_yintercept,
boolean print_table,
boolean calc_sumproduct,
boolean factor_equation,
int table_boundaries[], boolean allow_complex) {
String table_lower_bound = "", table_upper_bound = "";
boolean comma_reached = false;
try {
FileReader file = new FileReader("quadratics_settings");
BufferedReader settings_file = new BufferedReader(file);
String line = "";
/* reads line by line until there is no more text to read */
while((line = settings_file.readLine()) != null) {
calc_vertex = CharToboolean(line.charAt(0));
calc_yintercept = CharToboolean(line.charAt(1));
print_table = CharToboolean(line.charAt(2));
calc_sumproduct = CharToboolean(line.charAt(3));
factor_equation = CharToboolean(line.charAt(4));
allow_complex = CharToboolean(line.charAt(5));
for (int i = 6; i < line.length(); i++) {
if (line.charAt(i) == ',') {
comma_reached = true;
} else if (!(comma_reached))
/* build table_boundaries[0] */
{
table_lower_bound = table_lower_bound + line.charAt(i);
} else if (comma_reached)
/* build table_boundaries[1] */
{
table_upper_bound = table_upper_bound + line.charAt(i);
}
}
table_boundaries[0] = Integer.parseInt(table_lower_bound);
table_boundaries[1] = Integer.parseInt(table_upper_bound);
settings_file.close();
}
} catch(IOException e) { /* file not found - write default values */
calc_vertex = true;
calc_yintercept = true;
print_table = true;
calc_sumproduct = true;
factor_equation = true;
allow_complex = true;
table_boundaries[0] = -10;
table_boundaries[1] = 10;
try {
FileWriter file = new FileWriter("quadratics_settings");
BufferedWriter write_settings = new BufferedWriter(file);
write_settings.write("111111-10,10");
write_settings.close();
} catch(IOException f) {
System.out.println("Error encountered writing file\n");
}
}
}
public static boolean CharToboolean(char c) {
if (c == '0') {return false;}
else {return true;}
}
public static char booleanToChar(boolean b) {
if (!(b)) {return '0';}
else {return '1';}
}
public static double PlugIn(double x, double equation[]) {
/* ax^2 + bx + c */
return (equation[0] * Math.pow(x, 2)) + (equation[1] * x) + (equation[2]);
}
public static char GetSign(double input) {
if (input >= 0) {
return '+';
} else {
return '-';
}
}
public static void DisplayOptions(boolean calc_vertex, boolean calc_yintercept, boolean print_table,
boolean calc_sumproduct, boolean factor_equation, int table_boundaries[],
boolean allow_complex) {
System.out.println("\nSettings: ");
System.out.println("---------------------------------------------");
System.out.println("1. Calculate Vertex......................." + booleanToString(calc_vertex));
System.out.println("2. Calculate y-Intercept.................." + booleanToString(calc_yintercept));
System.out.println("3. Calculate Sum and Product.............." + booleanToString(calc_sumproduct));
System.out.println("4. Factor Equation........................" + booleanToString(factor_equation));
System.out.println("5. Print Table............................" + booleanToString(print_table));
System.out.println("6. Set Table Boundaries...................(" + table_boundaries[0] + "," + table_boundaries[1] + ")");
System.out.println("7. Allow Complex Solutions................" + booleanToString(allow_complex));
System.out.println("8. Back to Main Menu");
System.out.println("---------------------------------------------\n\n");
}
/* saves equation to "quadratics_equations" */
public static void SaveEquation(double a, double b, double c) {
String string_equation;
Vector<String> equations = new Vector<String> (0,1);
try{
FileReader file = new FileReader("quadratics_equations");
BufferedReader read_equations = new BufferedReader(file);
String line = "";
while((line = read_equations.readLine()) != null) {
/* copy in line by line to vector */
equations.addElement(line);
}
} catch(IOException e) {
System.out.println("Error reading file\n");
}
try {
FileWriter file = new FileWriter("quadratics_equations");
BufferedWriter overwrite_equations = new BufferedWriter(file);
/* overwrite with original equations */
for(int i = 0; i < (int)equations.size(); i++) {
overwrite_equations.write(equations.get(i));
overwrite_equations.newLine();
}
/* add newest equation to file */
overwrite_equations.write(EquationToString(a, b, c));
overwrite_equations.newLine();
overwrite_equations.close();
} catch(IOException e) {
System.out.println("Error writing file\n");
}
}
/* Removes chosen equation from "quadratics_equations" */
public static void RemoveEquationFromList(int line_number) {
int line_counter = 1;
Vector<String> equations = new Vector<String>(0,1);
try {
FileReader file = new FileReader("quadratics_equations");
BufferedReader read_equations = new BufferedReader(file);
String line = "";
while((line = read_equations.readLine()) != null) {
if(line_counter != line_number)
equations.addElement(line); /* copy all equations except chosen one
* to vector */
line_counter++;
}
read_equations.close();
} catch(IOException e) {
System.out.println("Error reading file\n");
}
try {
FileWriter file = new FileWriter("quadratics_equations");
BufferedWriter write_equations = new BufferedWriter(file);
for(int i = 0; i < (int)equations.size(); i++) {
write_equations.write(equations.get(i)); /* write equations back into file */
write_equations.newLine();
}
write_equations.close();
} catch(IOException e) {
System.out.println("Error writing file\n");
}
}
/* Displays equations stored in "quadratics_equations"
* User can choose to load an equation into equations[] for use in program,
* or can delete an equation from the file */
public static void DisplayEquations(double equation[]) {
String a = "", b = "", c = "";
int line_counter = 1, choice, remove;
try {
FileReader file = new FileReader("quadratics_equations");
BufferedReader equations = new BufferedReader(file);
String line = "";
while ((line = equations.readLine()) != null) {
System.out.print(line_counter + ". ");
GetEquationFromFile("quadratics_equations", line_counter, false, equation, false);
line_counter++;
}
equations.close();
System.out.print(line_counter + ". " + "Delete equation\n");
System.out.print("Enter choice: ");
choice = Integer.parseInt(GetConsoleInput());
if (choice == line_counter) { /* choice is to delete an equation */
System.out.print("Enter number of equation to remove: ");
remove = Integer.parseInt(GetConsoleInput());
do {
if (remove < 1 || remove > line_counter - 1) {
System.out.print("Error: Invalid choice. Please try again: ");
remove = Integer.parseInt(GetConsoleInput());
}
} while (remove < 1 || remove > line_counter - 1);
RemoveEquationFromList(remove);
} else
GetEquationFromFile("quadratics_equations", choice, true, equation, false);
} catch (IOException e) {
System.out.println("No saved equations.\n");
}
}
/* Reads "file_name" and finds specified line number. If load = true, this
function will load information from the line into equations[] for use by the
user. If print = true, the equation will be printed. */
/// did you mean equation[] or something else? equations[] doesn't exist
public static boolean GetEquationFromFile(String file_name, int line_number, boolean load, double equation[], boolean print) {
String a = "", b = "", c = "";
int line_counter = 1;
boolean file_exists = true;
try {
FileReader file = new FileReader(file_name);
BufferedReader read_file = new BufferedReader(file);
String line = "";
while((line = read_file.readLine()) != null) {
if(line_counter == line_number) {
int first_comma = line.indexOf(','); /* find first comma */
int second_comma = line.lastIndexOf(','); /* find second comma */
/* REMINDER: line.substr() takes in the size of the substring, NOT the
ending point as the second parameter (yes, that sucks) */
a = line.substring(0, first_comma);
b = line.substring(first_comma + 1, second_comma - first_comma);
/* c starts at the second comma, and the size of c is the size of the
whole line minus the size of a, b, and the 2 commas */
c = line.substring(second_comma + 1,
line.length() - (a.length() + b.length() + 2));
}
if(load) { /* "loads" values in to equation[] according to parameter */
equation[0] = Double.parseDouble(a);
equation[1] = Double.parseDouble(b);
equation[2] = Double.parseDouble(c);
}
if(print)
PrintEquation(equation[0], equation[1], equation[2]);
line_counter++;
}
} catch(IOException e) {
file_exists = false;
}
return file_exists;
}
/* converts numerical values of equation into string form.
* This will be used to write our equations to files */
public static String EquationToString(double a, double b, double c) {
/* I've heard that the Double.toString can cause some weird errors, this will need to
be tested. */
String equation = Double.toString(a) + ',' + Double.toString(b) + ',' + Double.toString(c);
return equation;
}
/* Prints equation with proper formatting */
public static void PrintEquation(double a, double b, double c) {
/* the output will be stored here */
String equation_output = "";
/* if the coefficient is 0, nothing happens */
if (a != 0) {
/* outputs the coefficient as long as it isn't 1 */
if (a != 1) {
equation_output += Double.toString(a);
}
equation_output += "x^2";
}
if (b != 0) {
/* outputs the sign of the coefficient */
equation_output += GetSign(b);
if (b != 1) {
equation_output += Double.toString(b);
}
equation_output += 'x';
}
if (c != 0) {
equation_output += GetSign(c);
if (c != 1) {
equation_output += Double.toString(c);
}
}
equation_output += "=0";
System.out.print(equation_output + "\n");
}
public static void Flipboolean(boolean boolean_to_flip) {
boolean_to_flip = !boolean_to_flip;
}
// public static void ClearScreen() { /// this function needs to be rewritten
/// and implemented or removed
// System.out.print("\x1b[2J\x1b[H" << flush;
// }
public static String GetConsoleInput() {
Scanner input = new Scanner(System.in);
String consoleInput = input.nextLine();
input.close();
return consoleInput;
}
}