java - TextIO.getln() does not get input? -
i'm newbie in java. i'm reading book introduction programming using java v7 , found problem code this:
public class createprofile { public static void main(string[] args) { // todo auto-generated method stub string name; string email; double salary; string favcolor; textio.putln("good afternoon! program create"); textio.putln("your profile file, if answer"); textio.putln("a few simple questions."); textio.putln(); /* gather responses users. */ textio.put("what name? "); name = textio.getln(); textio.put("what email address? "); email = textio.getln(); textio.put("what salary income? "); salary = textio.getdouble(); textio.putln(); textio.put("what favorite color? "); favcolor = textio.getln(); /* write user's information file named profile.txt. */ textio.writefile("profile.txt"); //subsequent output goes file textio.putln("name: " + name); textio.putln("email: " + email); textio.putln("favorite color: " + favcolor); textio.putf("yearly income: %1.2f%n", salary); /* print final message standard output. */ textio.writestandardoutput(); textio.putln("thank you. profile has been written profile.txt."); } }
the console not ask me input favorite color jump directly writing file process.
as when put favcolor input statement before salary, there seem no problem:
can please explain me why?
try removing textio.putln();
textio.put("what name? "); name = textio.getln(); textio.put("what email address? "); email = textio.getln(); textio.put("what salary income? "); salary = textio.getdouble(); //textio.putln(); textio.put("what favorite color? "); favcolor = textio.getln();
regards.
Comments
Post a Comment