AboutArtemus Harper Expertise I have a BS in computer science and am working towards a Masters degree.
Experience I have experience in Core Java, good background in Java swing/gui, some experience with JNI, Java reflection, and Java java.nio.*
knowledge of Java bytecode and annotations.
Basics in c++ and c#
Expert: Artemus Harper Date: 5/26/2008 Subject: string variable, user input
Question QUESTION: Hello,
I'm supposed to ask the user for the manufacturer, model, etc... of an aircraft. The answers to the questios should be saved as strings in respectively 'Man', 'Mod', etc...
How can I save the users answers? I know how to save numerical answers (int and double), but I don't know what to do now...
Please help!!
TY
ANSWER: When you save something numerically, it is converted from a string to some other kind of data. Instead of doing the conversion, you simply take the sting the user enters.
How you do this depends on how you are getting the user input.
E.g. if you are getting from the user's console (and using Java 1.6)
String man = System.console().readLine("Enter manufacturer");
---------- FOLLOW-UP ----------
QUESTION: I'm using ConTEXT.
I'm getting the input with the command
System.out.println("Enter the manufacturer: ");
Should it then be:
System.out.println("Enter the manufacturer");
Man = in1.readLine();
and then use the same way for model, etc... or other way?
Afterwards I'm supposed to put all the information of the several aircraft in a "JAVA Vector or List"....
Small explanation, for I can't find it in the book....
TY!!!
Answer Yes, you can do the same for a model. Then you want to create a class that can keep all of these variables, and store these into a list, such as ArrayList.