java - Checking user input against information in a .txt file -



java - Checking user input against information in a .txt file -

i creating project in currency exchange. 1 of steps have user input type of currency want convert dollar. have while loop check , create sure input right against text file.

the text file has

cd 1.05 0.93 mp 0.11 0.095 european union 1.554 1.429

so person come in cd mp or european union not sure how check it. using eclipse , txt file in project folder.

public class communication { public string askforcode(){ string currencycode = joptionpane.showinputdialog(null, "we exchange next currencies: \n " + "cd (canadian dollar)\n" + "mp (mexican peso) \n" + "eu (euro) \n" + "enter currency code"); file myfile = new file("dailyrates.txt"); while (!currencycode.equals){ } homecoming currencycode; }

would utilize file.next line validate it?

you utilize showoptiondialog...

object[] options = {"cd", "mp", "eu"}; int n = joptionpane.showoptiondialog(null, "enter currency code", "from currency", joptionpane.yes_no_cancel_option, joptionpane.question_message, null, options, options[2]);

or more restrictive showinputdialog...

object[] possibilities = {"cd", "mp", "eu"}; string s = (string) joptionpane.showinputdialog( null, "enter currency code", "from currency", joptionpane.plain_message, (icon)null, possibilities, "cd");

that restrict users available options wanted them use

see how create dialogs more details

you read text file, storing values in array, list or map , utilize codes straight within dialog add together more flexibility...

java file validation loops

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -