Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
i am having some issues with this question for my homework and was wondering if anyone has any ideas or insights to the answer really struggling ,,,,
You are to amend the program you created last week, this time however the program will ask you to
type the names that need to be stored. Once this is complete the program will display the names in
alphabetical order and display the number of characters for each name and the number of vowels
each name has.
Since this is homework, I'll give you a hint. If you've studied the Java Collections, you can stored the names in alphabetical order. If you've not got to collections yet, the you simply save them off as Strings as they come in.
When it's time to display them in alphabetical order you could:
- sort them before you display them
- or brute force it. Loop thru your storage of names and display all the A's. Then loop thru picking up the B's.
As for counting vowels, look at the Java documentation for the methods that are on the String class. Hint - look for methods that return an "int".
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm trying to make a program that :
accepts a string of characters(initial), i.e. a DNA sequence.
The number of characters that are accepted should be given as an input before inserting the string.
Accepts a number, then receives the same number of characters
Find all the possible 'mutations' that could occur from input 2, and check in input 1 whether there are occurrences of these mutations.
Mutations are a number of strings that could be made from input 2. For example, with AGGT, GAGT, GGAT, TGGA, AGGT, ATGG, and AGTG.
So a sample run of the program would be like
2
6 4
ATGGAT
AGGT
3
Usually, when you ask a question on this site, you should show us the effort you put in your work and exactly show or tell us where do you think what you did does not work.
I am not giving you an answer, but I'm giving you better: the opportunity to learn more on the subject. You can learn about what we call in java "regular expressions" here:http://docs.oracle.com/javase/tutorial/essential/regex/
If you make an update of your query showing us what you did, people might be more encline to help you. Stackoverflow has a great community of programmers who are willing to help you just as long as you show them respect by showing where you failed and not directly asking answers for your type of problems !
Learning about regex will definetly help you out to solve this situation. If you build a method using regex and matches and you have issues with it, post what you did and what was intended with this method !
Hope it helps you :)
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am writing a piece of code that allows users to enter test scores. I then need to use the Math.max and Math.min to keep track of max and min and display the answer. I am not sure where I type that code or how I type that code.
Please let me know what pieces of the code would be helpful to post!
Thanks in advance!
Start by breaking down the problem into steps and figure out what you need to know. In your case you need to know four things:
How to get input from the console
How to compare values
How to conditionally change values
How to display things to the console
One and four you can search up pretty easy. Look into "Hello world" and other such starter programs for Java. Two and three you should look up "if" statements for Java. Hope this sets you on the right track.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I'm working on my first big project and one thing I need to do is create a log of all the ships in a game and all their stats, their name, class etc... There must be at least over 100 ships. I thought about using a Hashmap, but I would need more than one value per key. I thought about doing a bunch of string arrays, but I think that would take too much memory. Should I read the values in from a .txt file? Any suggestions would be greatly appreciated, and thank you for your time. :D
What is the unique identifier for a ship? You can simply create a hashmap using that unique identifier as the key and the ship instance as the value. In addition, there is nothing preventing you from using a MultiMap to store a collection of values at each key if that makes semantic sense. But this question is rather poorly defined with respect to what you actually want this 'log' to do.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
So I've been giving a project for school and was just hoping for reassurance towards the decision making I do.
My java skills are extremely basic and need to improve drastically soon! I just seem to be getting nowhere atm :P
Anyway, back on topic.
My first task is to create an interface directory that can do the following
Keep in mind this is assessed work therefore please don't provide answers. I have enough time to complete this since I've started early!
My initial approach for going about this task is using a Linked List. I don't know what you guys think about that? I may be completely wrong but based on the topics we have covered in School. LinkedList definitely seems suitable. I can add, get and remove.
Cheers for reading guys!
You are along the right lines. The java.util.Collections package will contain most of what you need.
I would actually use an ArrayList rather than a LinkedList as it is faster for random access and sorting.
However note that it says you should be able to find people efficiently and look them up by name.
That suggests using something like a TreeMap structure, mapping name to a class containing information on each person. Store the names as "Surname, Forename" and they will be sorted correctly.
That will only allow lookups based on the complete and correct name though. If you want to search for partial names the map is less useful.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I have near about 1 million entries in my database table and
I need to use some logic by which I can search within minimum time,
is there any algorithms or logic by which i can get result within less time.
I tried sorting table alphabetically but till it is taking much more time.
If you have any algorithm or logic then please suggest code in Java.
Looks like you need to ad in index to your database table.
If you tell what database you are using, people can give more specific help.
It dosent matter how much records you have as long as your databse is properly normalised and is having proper index. Having said that, the only difference that will make is how you are using indexes. You cannot do much in java, but your db and its design will play a significant role.