Help with Java Program please?

Help with Java Program please? Topic: Case string c++ example
July 16, 2019 / By Bambie
Question: In this program im trying to check to see if you can create a word with a given string. for example If the list was c,s,a,d,,f,g Then a possible word i can make is sad. The problem is have is if the list has mutliple letters example h,e,e,e,l,l,l,l,l,o I want the program to output hello but my program outputs h e e l l l l o and i cant seem to make it so it only find hello Heres the code : public class Words { Words(String x) { words = x; letters = new ArrayList(); } public void splitWord() { for(int x=0; x empty = new ArrayList(); // while(in.hasNextLine()) //{ String line = in.nextLine(); for(int x=0; x
Best Answer

Best Answers: Help with Java Program please?

Addison Addison | 4 days ago
Its good that you have thought of something like this and trying to achieve the proper outcome. Though itself is kinda tough thing to achieve ,yet everything is possible in java words ,in your case you just need to have efficient and intelligent algorithm to help you. Pardon me for being busy enough for not to type the whole program but yes i have idea about the subject you talking about and can be easily achieved with help below links(claims to have solution) you need to fit them in your program and there you go.. http://forums.sun.com/thread.jspa?thread... http://stackoverflow.com/questions/74608... http://www.daniweb.com/forums/thread2411... If you are looking for extensive spell checker kinds software design then yes its possible with apache common collections its damn easy see the below link http://sujitpal.blogspot.com/2007/12/spelling-checker-with-lucene.html Hope this resolves your issues Cheers:)
👍 196 | 👎 4
Did you like the answer? Help with Java Program please? Share with your friends

We found more questions related to the topic: Case string c++ example

Addison Originally Answered: Help With Java Program?
A few things I see. First, always compare strings this way: if(string1.equals(string2)) That's because Strings are objects and if you use the == all that does is compare memory locations for objects. Second, if you're checking the same value over and over with if statements, you want to use "if" and "else if". It's more efficient since your program will stop checking the others when it finds the correct value: if(mood.equals("Good"))... else if(mood.equals("Fine"))... else { //default behavior } You want to use a last "else" statement as the catchall if none of the previous if/else if statements were true. I'd bet nothing happens because y ou don't have a catchall else statement.
Addison Originally Answered: Help With Java Program?
Why roll your guy or woman while there is in all probability a calendar widget you could reuse? by using the way, the Java API itself delivers many sensible instructions and interfaces: Date, Calendar, GregorianCalendar, DateFormat, and SimpleDateFormat.

Talmai Talmai
Why roll your own when there is in all likelihood a calendar widget you can reuse? By the way, the Java API itself provides many useful classes and interfaces: Date, Calendar, GregorianCalendar, DateFormat, and SimpleDateFormat.
👍 80 | 👎 0

Percy Percy
is this is working code? I am getting lots of copilation errors.Can you please post the proper code.
👍 77 | 👎 -4

Percy Originally Answered: Help with a java program?
So we'll make an array, of length 18, and thus with indices 0-17. Each index will represent the number of rolls possible for making that number, only we'll adjust the index up by 1 so we go from 1-18 instead of 0-17. For example, index 0 will store the amount of ways you can roll 1, index 1 will store the amount of ways you can make 2, all the way up until index 17 stores the amount of ways you can roll 18. We'll start off by declaring our integer array and setting it to size 18: int[]rolls = new int[18]; By default it is filled with all 0's, which is fine to start. We now have to fill it with the proper values. Basically what we'll do is loop through all possible combinations of rolls, and add their sums. We'll do this with a series of 3 nested for loops - the outermost will be the roll of the first dice, the middle the second dice, and the innermost the third dice. This way, the inner loop will run once for each value of the middle loop, which will in turn run once for each value of the outer loop. So for every possible value of the first dice, we'll find every possible value for the second dice, and for every possible value of the first two dices, we'll find ever possible value of the third dice. It will work something like this: 111, 112, 113, 114, 115, 116, 121, 122, 123, 124, 125, 126, 131, 132, 133, 134, 135, 136, 141, 142, 143, 144, 145, 146, 151, 152, 153, 154, 155, 156, 161, 162, 163, 164, 165, 166, 211... and so on. The code to do this is as follows: for (int a = 1; a <= 6; a++) { for (int b = 1; b <= 6; b++) { for (int c = 1; c <= 6; c++) { int value = a+b+c; rolls[value-1]++; } } } So for each possible roll we compute the value by adding the three dies and then go to that position in the array and increase the number of possible ways to make this value by 1. At the end we just need to print all these values: for (int x = 0; x < rolls.length; x++) System.out.println((x+1) + " " + rolls[x]);

If you have your own answer to the question case string c++ example, then you can write your own version, using the form below for an extended answer.