how can i write a java code to display data based on the user input. The data displayed is not input by the...
up vote
-6
down vote
favorite
e.g how to write a code that will display a string based on the input by users. N/B the strings are already initialized within the code
java
closed as unclear what you're asking by Unheilig, Matsemann, DaveyDaveDave, gnat, Grimthorr Nov 9 at 10:40
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
up vote
-6
down vote
favorite
e.g how to write a code that will display a string based on the input by users. N/B the strings are already initialized within the code
java
closed as unclear what you're asking by Unheilig, Matsemann, DaveyDaveDave, gnat, Grimthorr Nov 9 at 10:40
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
up vote
-6
down vote
favorite
up vote
-6
down vote
favorite
e.g how to write a code that will display a string based on the input by users. N/B the strings are already initialized within the code
java
e.g how to write a code that will display a string based on the input by users. N/B the strings are already initialized within the code
java
java
edited Nov 11 at 18:02
asked Nov 9 at 8:02
Rthirteen
12
12
closed as unclear what you're asking by Unheilig, Matsemann, DaveyDaveDave, gnat, Grimthorr Nov 9 at 10:40
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
closed as unclear what you're asking by Unheilig, Matsemann, DaveyDaveDave, gnat, Grimthorr Nov 9 at 10:40
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
I think what you are looking for is .equals() method of String class which can compare two strings. For example:
if(scanner.next().equals(a)) {
// do something
}
add a comment |
up vote
0
down vote
I'm not very clear about your question. Do you mean user will input a variable name, and the program need to display the value of this variable?
If my guess correct, you just need a map. For example, if your variable value type is Integer, you can create:
Map memory = newHashMap();
and put your initialized variable into "memory" by: memory.put("var", 1).
to retrieve the variable: if ( memory.containsKey("var") ) return memory.get("var");
the user will input a variable possible lets say a dog disease symptom and the program with already initialized data for diseases will display the disease based on the symptom input
– Rthirteen
Nov 9 at 8:14
If you mean human language understanding, you can try to google "NLP", it's part of AI scope.
– cuble
Nov 9 at 8:26
The Map define code should be:Map<String, Integer> memory = newHashMap<String, Integer>();
. I'm not familiar with the post edit rules
– cuble
Nov 9 at 8:44
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
I think what you are looking for is .equals() method of String class which can compare two strings. For example:
if(scanner.next().equals(a)) {
// do something
}
add a comment |
up vote
1
down vote
I think what you are looking for is .equals() method of String class which can compare two strings. For example:
if(scanner.next().equals(a)) {
// do something
}
add a comment |
up vote
1
down vote
up vote
1
down vote
I think what you are looking for is .equals() method of String class which can compare two strings. For example:
if(scanner.next().equals(a)) {
// do something
}
I think what you are looking for is .equals() method of String class which can compare two strings. For example:
if(scanner.next().equals(a)) {
// do something
}
answered Nov 9 at 8:08
Naeem Khan
649
649
add a comment |
add a comment |
up vote
0
down vote
I'm not very clear about your question. Do you mean user will input a variable name, and the program need to display the value of this variable?
If my guess correct, you just need a map. For example, if your variable value type is Integer, you can create:
Map memory = newHashMap();
and put your initialized variable into "memory" by: memory.put("var", 1).
to retrieve the variable: if ( memory.containsKey("var") ) return memory.get("var");
the user will input a variable possible lets say a dog disease symptom and the program with already initialized data for diseases will display the disease based on the symptom input
– Rthirteen
Nov 9 at 8:14
If you mean human language understanding, you can try to google "NLP", it's part of AI scope.
– cuble
Nov 9 at 8:26
The Map define code should be:Map<String, Integer> memory = newHashMap<String, Integer>();
. I'm not familiar with the post edit rules
– cuble
Nov 9 at 8:44
add a comment |
up vote
0
down vote
I'm not very clear about your question. Do you mean user will input a variable name, and the program need to display the value of this variable?
If my guess correct, you just need a map. For example, if your variable value type is Integer, you can create:
Map memory = newHashMap();
and put your initialized variable into "memory" by: memory.put("var", 1).
to retrieve the variable: if ( memory.containsKey("var") ) return memory.get("var");
the user will input a variable possible lets say a dog disease symptom and the program with already initialized data for diseases will display the disease based on the symptom input
– Rthirteen
Nov 9 at 8:14
If you mean human language understanding, you can try to google "NLP", it's part of AI scope.
– cuble
Nov 9 at 8:26
The Map define code should be:Map<String, Integer> memory = newHashMap<String, Integer>();
. I'm not familiar with the post edit rules
– cuble
Nov 9 at 8:44
add a comment |
up vote
0
down vote
up vote
0
down vote
I'm not very clear about your question. Do you mean user will input a variable name, and the program need to display the value of this variable?
If my guess correct, you just need a map. For example, if your variable value type is Integer, you can create:
Map memory = newHashMap();
and put your initialized variable into "memory" by: memory.put("var", 1).
to retrieve the variable: if ( memory.containsKey("var") ) return memory.get("var");
I'm not very clear about your question. Do you mean user will input a variable name, and the program need to display the value of this variable?
If my guess correct, you just need a map. For example, if your variable value type is Integer, you can create:
Map memory = newHashMap();
and put your initialized variable into "memory" by: memory.put("var", 1).
to retrieve the variable: if ( memory.containsKey("var") ) return memory.get("var");
answered Nov 9 at 8:10
cuble
15617
15617
the user will input a variable possible lets say a dog disease symptom and the program with already initialized data for diseases will display the disease based on the symptom input
– Rthirteen
Nov 9 at 8:14
If you mean human language understanding, you can try to google "NLP", it's part of AI scope.
– cuble
Nov 9 at 8:26
The Map define code should be:Map<String, Integer> memory = newHashMap<String, Integer>();
. I'm not familiar with the post edit rules
– cuble
Nov 9 at 8:44
add a comment |
the user will input a variable possible lets say a dog disease symptom and the program with already initialized data for diseases will display the disease based on the symptom input
– Rthirteen
Nov 9 at 8:14
If you mean human language understanding, you can try to google "NLP", it's part of AI scope.
– cuble
Nov 9 at 8:26
The Map define code should be:Map<String, Integer> memory = newHashMap<String, Integer>();
. I'm not familiar with the post edit rules
– cuble
Nov 9 at 8:44
the user will input a variable possible lets say a dog disease symptom and the program with already initialized data for diseases will display the disease based on the symptom input
– Rthirteen
Nov 9 at 8:14
the user will input a variable possible lets say a dog disease symptom and the program with already initialized data for diseases will display the disease based on the symptom input
– Rthirteen
Nov 9 at 8:14
If you mean human language understanding, you can try to google "NLP", it's part of AI scope.
– cuble
Nov 9 at 8:26
If you mean human language understanding, you can try to google "NLP", it's part of AI scope.
– cuble
Nov 9 at 8:26
The Map define code should be:
Map<String, Integer> memory = newHashMap<String, Integer>();
. I'm not familiar with the post edit rules– cuble
Nov 9 at 8:44
The Map define code should be:
Map<String, Integer> memory = newHashMap<String, Integer>();
. I'm not familiar with the post edit rules– cuble
Nov 9 at 8:44
add a comment |