• Post Reply Bookmark Topic Watch Topic
  • New Topic

Fresh Meat - Extremely Simple Numerology Word Processing Program - Assistance Requested!  RSS feed

 
Blake Boyd
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wish this question was closer to simple or small... (perhaps it is for the right reader?)

A very brief background of me. I am incredibly new to the world of Java Programming (I'm actually waiting for the JDK to finish downloading now! :P) and have a few tutorials lined up that I have been shooting through, but I must be honest with both you and myself, I picked up Java tonight with a very simple goal in mind. I have need of a program that will assist me in my numerology number crunching and the like. I devised a neat premise for the deal, or paper rough draft if you will, and know it must be painfully easy to accomplish (I'd likely be able to accomplish this in python easier though...), and as such feel it's absolutely possible I will have an alpha version program running on my desktop by tomorrow. This is of course reliant on the speed to which one knowledgeable can reply, and if the Java language is flexible enough to carry out this seemingly easy of tasks. Oh, and any help is greatly appreciated, so please note I am incredibly patient. You all could look at this and wait to respond till next week if you wanted to, the aid you have done me in the process is the same as a reply made in good haste.

Onward to the "simple" program.

EDIT: the stuff written below in this post is less clear and more early-stage than that in my next reply, please skip if you wish to avoid a headache

EDIT: the stuff written below in this post is less clear and more early-stage than that in my next reply, please skip if you wish to avoid a headache

EDIT: the stuff written below in this post is less clear and more early-stage than that in my next reply, please skip if you wish to avoid a headache

Yes I said it thrice! Though I must admit there is some additional premise below in this post that won't be in the clearer latter. Proceed with caution.

Every letter in the English language will be given one of 9 values, an example of what I mean using imaginary made-up program language that allows multiple variables defined in one line separated by spaces with a break between sets where only lowercase is used:



I (that is I, not a program or apparition of magic) will compile lists of related words into a series of text documents (.txt). These words will be either all lower-case, or with a capitol letter at the beginning, have a space between them, and no other punctuation.
An example:

dictionary1.txt
silly sad happy fun great hairy tall small petite grand magnificent gross ugly odorous gangly fat big angry content excited fulfilled loving emotional emo attractive hot hawt phat


The program will translate each word from "dictionary1.txt" into their base numerical value (basenv), a value calculated by first converting each letter of the word into a number, using the pre-defined values I listed above, and then adding these numbers together. It then adds digits in the sum of the basenv, or base numerical value , together to get the words' compressed numerical value (compnv). It may have to add the digits together several times to fully compress down to one single digit, I will explain in a moment if this is hazy. It will internally store the words into 1 of 9 lists, depending on that compressed numerical value, and upon completion of reading and translating every word in dictionary1.txt, will print all stored words into 1 of 9 .txt documents.

A word like AIR, or 1 + 9 + 9, becomes 19, and then 1 + 9 becomes 10, with 10 (two digits, not one yet) becoming 1 + 0 = 1. So the Base numerical value for AIR, was 19, and then 10, and the compressed numerical value was 1.

Air gets added to a list called "1" with other words that reduced to 1, until all words are processed as mentioned above, at which point I should be able to open my 1.txt in the same directory as the program and the dictionary1.txt and see the word AIR somewhere among the words.

An example of the expected result to follow after this snip of lame, incomplete pseudo code:



Now as promised, when the program finishes analyzing and sorting the words in the example dictionary1.txt above, the contents of 1.txt - 9.txt should look as follows:

dictionary1.txt(for reference)
silly sad happy fun great hairy tall small petite grand magnificent gross ugly odorous gangly fat big angry content excited fulfilled loving emotional emo attractive hot hawt phat

1.txt
content

2.txt
magnificent ugly angry attractive

3.txt
happy great small petite gangly

4.txt


5.txt
silly fun emotional

6.txt
sad fulfilled emo

7.txt
hairy excited loving hot hawt

8.txt
grand odorous

9.txt
tall fat big phat

Now this is only if my manual non-computer assisted number crunching was 100% accurate, and the entire process still took me several minutes to complete, for an example of very few words! A computer program like that I propose and draft above would not only afford me the luxury of not having to worry about whether or not I miscounted or added a word incorrectly, but it would also allow me to sort through thousands of words and compile very large lists I can then arrange and organize into graphics and flow charts (or just more precise .txt result category groupings) with all my newly learned skills and examples a gent or gal like yourself could impart upon me! Think of the glorious fun I could have with your aid, and I shan't ever forget you for it, and am prone to ask you for new (smaller) tips in the future when I get really into Java. For me, getting a program I had in mind out of the way on the first page helps me want to propel my learning of the language it's coded in to the next level, and I just know this will boost my motivation... because sooner or later, and by that I mean sooner, I will be thinking of ways to refine the code and perhaps find myself adding a graphical user interface, and finding ways of making those graphs I mentioned... I just need help setting up a base program with minimal to 0 gui so that I can expand my knowledge of the language and build wonderful works of creativity off of it.

I thank you humbly for considering your reply, and hope this is simple enough that you could point in me in the direction of the commands I will be using, help me set up the proper syntax, or even throw me a large bone in the form of an example you hastily typed into your browser without error-checking off the top of your head. I mind not the amount of help, and before you wonder this, because I have seen hostility toward newbs on other forums and places of support, I am NOT a student with any college or university, or any programming class whatsoever. By helping me you are NOT helping me with a homework assignment, this is for my own fun, and subsequently, my own learning. You aren't cheating by throwing me an example or two or three, because as I said, this is the way I learn best. With all of that disclaimer nonsense out of the way, thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you,

Still have a glitch in my thankyou_paste() program I see, :}

Good night all!
-Blake

 
Campbell Ritchie
Marshal
Posts: 56553
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Write down in simple words what the formula is going to be. Do it before you install Java®. Once you have a formula, algorithm or process written down, it is usually easy to convert to code.
 
Blake Boyd
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much for the warm greeting! I am excited to be here, and am very happy to report that an internet outing in my local area led me to do just that before signing on tonight! Hopefully now when you look at my pseudo-code you notice I have a much better idea of how this will work, and assuming I made no errors, I now know exactly which questions I must ask. Also, thank you once more to any humble reader who takes the time to follow along with me and offer assistance. It really does mean the world to a fresh Newb like myself who likes to jump right into things (I mean it!).... and luckily enough, perfect efficiency and programming style is not needed here, for I am this programs only user, and could wait all day for it to finish. (An example of diminished efficiency being a repeat of certain code blocks bringing the overall file size a smidge higher). Now onto my latest study (the fun part).

First, here is the annotated walk-through of the updated code. I used a C-based IDE to write this, so if you wish for highlights you can copy it into a window like that, but for the most part the commands given were of my own device and creation and as such, shall never highlight. Also, and this applies for both examples of code below, I started placing the framework for checking which Library is used at any one time and moving over to the next so that all library files numbered consecutively are processed before the results are posted, but I believe I didn't finish it off. So while you may notice this present to an extent, it currently has no functionality other than the correct variable names are set-up and such.



In extremely plain English that reads like this:



Configuration of Variables (only seen and set once)

Main loop()
Choose/Set the current Library# to use.
Use Library# to assign correct path for library#.txt in root folder.
Begin embedded loop / interior loop nextWord();

Embedded loop()
Choose/Set the current word to be looked at
Load the library *NOTE* rather than redundantly loading this, I should place it outside the embedded loop somewhere. ignore please.
Load the word we chose to look at.
If we are attempting to look at a word that isn't present, we must jump to the bottom and finish printing results.
If a word is found, let us proceed.

Looks at the first letter, or next letter, depending on which value is assigned. We will remember this letters numerology value!
Shift to the next letter in question.
Numerology value of the latest letter, plus that of the previous gives us a new Sum we will use later.
If the new Sum hasn't changed upon adding the two number values together, we must not have added a letter to it and the word is completely analyzed.

Lets say the word is now complete at this point.
Store word1 or whichever word it is (counting upward as we progress) as the value of all it's letters added together.
Shift to the next word in question so we may repeat this process until there are no words left.

Lets say the word wasn't complete at this point.
First let's check to see if our currentSum of letters is a single digit.
If not, let's add the digits of the value together to make it a single digit.

If it is already a single digit, that's great! Let's go ahead and save our work under a different storage container so we can continue to use the old one which was ever so helpful to carry new values.
Let's also shift to the next letter of focus once more.

If we still have words to work with, we will continue doing all of the above until we do not.

When we don't have any words to work with, because the word I went to fetch resulted in a value of nothing there or 0,
I will print a friendly message to let the user know I'm done assigning values to everything and ready to begin the next step.
Now, as opposed to earlier, I will roll back through my flash cards of words 1 by 1, placing them in 1 of 9 piles my author believes are called arrays.
Each time I add a word to a pile, I will shift the word# backward 1 so I can sort a new word in question, until I am finished and left with no more words to sort.

At this point I let the user know I have sorted the words into categories (or arrays) and am about to place each array into it's own .txt document!
And exactly as promised, this is what I do. My author has chosen not to alert the user I've finished this step, for he believes it to take less than 10 seconds.

Fin.


Here is a complete walkthrough showing the loops that fire in consecutive order. If one was to follow the path the machine takes, this displays just that, and I mind you I labeled repeat chunks and cycles c1 through cx to help reader comprehension, but kind of lost track in at least one location... nevertheless I left them in because it clues you into the fact that the code has been expanded and repeated sometimes several times to simulate going through all the different loops to conclusion. Also note, I may have placed my {} in a few incorrect positions here, because this machine-walkthrough was created with the unfinished code. (By unfinished I mean I placed a few more bits here).

One final note about this "complete walkthrough" that ties into my last line above, is that due to revisions being made to code blocks as I reached them like a naughty coder, incorrect code may linger above that was fixed in the repeated blocks down below! If you follow me along without reading into anything the system isn't at that time, however, you should always see the correct code sequence. For the most part, redundant codes that aren't firing at that time I removed to improve focus on the path the machine will take. (This too saves you from having to jump over more than one code block to see where the machine goes next).



And with that, I am "finally" done revealing to you my code samples! The follow along was perhaps the most inconsistent because it was written without the latest revised program (it actually helped me revise it), but as I said, if you followed along and skipped when prompted hopefully you have a good idea of what I wish to do.

That brings me to my next slice of fun. As I mentioned above, doing this exercise now allows me to ask the right questions. I am posting all questions on my mind here tagged with either (known) or (unknown) depending on if I know how to do that particular thing. I list all unknowns, presently for myself, so you don't need to tell me for instance the proper syntax for a variable in Java, as I will most likely know this the next time I come after independent research. If however, you are one of those types who finds these simple questions remarkably easy to answer, do post off the top of your mind said syntax. You aren't hurting my learning process one bit, and are helping me excel! Again though, I don't expect anyone here to have to go out of their way to research something I need to research myself, so I leave the amount of simple questions listed below you answer to your own discretion.

Regardless, when a question changes from the (unknown) state to (known) I will post the answer in brackets beside it, so newbs like myself can quickly see how to do everything found in this easy program, and perhaps this will be a decent exercise for beginners to any new code. Tis my hope at least!

A. What is the Java equivalent of a "setup" or single-run "loop" placed at the top of the program? (unknown)
B. What is the Java equivalent of declaring a float, integer, and string variable? (unknown)
C. In Java, how does one assign one value to multiple variables? Must a new line be added for each value to each group? (above I use the format: int [a, b, c] = 1; [d, e, f] = 2;) (unknown)
D. Does java have a plugin or "library" that allows one to use simple commands to:

1. Load a .txt file, or word containing file of other extension? (above I use the format: load library(path to file);) (unknown)
2. Allow the programmer to target or load a word from that text file for additional review? (above I use the format: load word(word#);) (unknown)
3. Allow the programmer to target or load a letter from that word? (above I use the format: load letter(letter#);) (unknown)

E. Does java allow you to check an integer variable to see if it is a single digit? If so, how? (above I use the format: if currentSum != 1digit) (unknown)
F. If the prior question is yes, does Java have a command that allows you to split an int var into its separate digits for maths? (above I use the format: currentSum = the digits of currentSum added together; which is human speak) (unknown)
G. Does Java allow one to break from a loop, for instance an if or else statement? If so can one break to the main loop? (above I use the format: break; or: break to void loop(); or break to looptitle();) (unknown)
H. What are the various commands for printing a message, whether they be to window, cmd prompt window, or box with 'ok' prompt? (above I use the format: print "string") (unknown)
I. How can strings be stored consecutively or in any order for use at a later time? I believe these are called arrays, if so, how do they work in Java? (unknown)
J. Does java have a plugin or "library" (perhaps the same one asked for above) that allows one to save the values of a particular array (or string-storing block if they aren't called arrays) to a .txt document in the root directory of your program? (unknown)
K. When embedding a variable inside a string, what is the proper syntax used so the program reads it correctly? (Above I use the format: wordorstring'variable'; where if 'variable' = 1, the machine reads wordorstring1) (unknown)
L. What is the proper way to take one variable and set it equal to the other, without accidentally doing it the opposite way around. (Above I believe I was inconsistent.) (unknown)
M. What is the proper syntax for adding your own function (or loop) within the main loop? And how might one jump to it from a code block? (Above I use the format: functionorloopname() {})(to jump I simply list it: functionorloopname();)

I believe this covers all questions in my mind, the lack of answers to which are the only barriers stopping me from completing my first Java program, or you can think of it as my slightly elaborate "hello world!". With these questions answered, I will have the power to do very many things with this lovely language, as most of what I do when programming evolves around these simple concepts. Again, if some of these questions offend you for their simple-ness, you can withhold replying and will likely find I answered them for myself or received aid from someone who doesn't mind, so please don't take any offense to my complete lack of knowledge.

In the future I will be learning (completely on my own accord w/o any help whatsoever!) the following list of concepts, and posting an update to this forum that alerts other fellow noobs in tutorial format how to incorporate these concepts into their own projects:

1. Adding a simple GUI, in terms of the project above, allowing the user to select which file they want to load by means of a browse window, and also allowing the user to choose which directory they would like the output files.
2. Adding the ability to display numerical data attached to strings or photos, or any noun really into simple graphs, flow-charts, or other helpful graphics.
3. Learning of ways to further process numbers and maths; I have a suspicion I will be doing more complex calculations of the numerological values of words, whether that means storing all 9's that pop up while number crunching in their own slot next to the 'final word value' or maintaining integrity of any number for that matter the user doesn't wish to add to the final sum. This is simple to do, yet placed here as it is on the "wishlist" and goes above "minimal functionality". (An example of what I mean, say the user doesn't want 4's added, while crunching the word CAT or 312, the program would display 42 as opposed to 6.)(Another example, user doesn't wish the number 3 to be added in the word Library aka 3929197, the program will display 337 as opposed to 4. The value of the word doesn't change, but certain numbers once reached, or even those present in the letters without addition themselves would be withheld from the last value)(One final example differentiating the last bit I had to add to this with the word Lilly; the program withholds addition of any letter with a value of 3, so 39337 becomes 3337.)
3b. This step is only really useful to me, but showing how I added complexity at various processes of the number crunching may help some I imagine trying to do projects that for one reason or other must withhold certain values while + - x or /ing.
 
Campbell Ritchie
Marshal
Posts: 56553
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will never get anywhere with something that long. Delete 99% of it and get the other 1% working. Then replace another 1% and get that working. Then you only have another 98 stages
Start by working out how you will get a j or s to code as 1, etc. Until you have got that working, forget all about the rest.

And as for “something that long”, I am going to have to shorten your lines for reasons explained here.
 
Campbell Ritchie
Marshal
Posts: 56553
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Blake Boyd wrote:Thank you very much for the warm greeting!
. . .
In the future I will be learning (completely on my own accord w/o any help whatsoever!) . . .
You're welcome

I am afraid that learning without help is synonymous with learning wrong.
I can promise you that trying to do so much all at once will not work. It looks as if you had a preconception about what will work, but you can only get something to work by dividing it into small parts.
I can also promise that nobody will help if you post anything that long.
 
Blake Boyd
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wish this question was closer to simple or small... (perhaps it is for the right reader?)

A very brief background of me. I am incredibly new to the world of Java Programming (I'm actually waiting for the JDK to finish downloading now! :P) and have a few tutorials lined up that I have been shooting through, but I must be honest with both you and myself, I picked up Java tonight with a very simple goal in mind. I have need of a program that will assist me in my numerology number crunching and the like. I devised a neat premise for the deal, or paper rough draft if you will, and know it must be painfully easy to accomplish, and as such feel it's absolutely possible I will have an alpha version program running on my desktop this week. This is of course reliant on the speed to which one knowledgeable can reply, and if the Java language is flexible enough to carry out this seemingly easy of tasks. Oh, and any help is greatly appreciated, so please note I am incredibly patient. You all could look at this and wait to respond till next week if you wanted to, the aid you have done me in the process is the same as a reply made in good haste.

Program Premise:
Devise a code that allows a user to (a) load a .txt library of words separated by spaces, (b) will take these words and translate them into numbers, depending on what numbers were assigned to which letters in the init, (c) print the results to separate .txt files, one file to contain words for each single-digit number they compress to.

If the initial library only contained the word "CAT" and "DOG", the machine would translate the two into "312" and "467" respectively (assuming these were the values I chose for the letters), further compress them to "6" and "8" by adding the numbers together repeatedly until they are a single digit, and upon completion leave the word "CAT" in a .txt document titled "6.txt" and the word "DOG" in a text file titled "8".

Pseudo-Code Examples I have devised:
Note: While proper practice to aim for highest efficiency and lowest redundancy, I only aim to achieve a result with this code. Further attempts at revision can be made after the alpha works, so keep this in mind!

Init:
to allow this post to remain clear and of low word-count, let us assume it was correctly set-up. This includes assigning A, J, S the value 1; B, K, T the value 2; so on.

Main Loop:


Word Processing Loop:


Results Loop:


English-Translation of Code:

Load next (or first) Library.

Load next (or first) Word from Library loaded.

Load next (or first) Letter from Word loaded.
Store value the pertains to init for the Letter loaded,
Add value of next letter to first.
Check if word is complete yet. If so, add word to array it corresponds to and restart loop, loading the next word and repeat.
If no words are found, the current loaded Library is empty. Attempt to load the next and restart.
If no more Libraries are found, print values (words) stored in arrays to corresponding text documents.

That's it! This is rather simple, but of course impossible for me with my lack of knowledge of the Java syntax at the moment.... so feel free to help me answer some of those questions I have floating around in my head below, and I will promptly update my post with your answer for others and get straight to work bringing this little code to realization! As I can't stress enough, thank you a million for reading this far, and should you be thinking of a way you can render me aid, thank you three more times on top of that!
 
Campbell Ritchie
Marshal
Posts: 56553
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Blake Boyd wrote:Thank you very much for the warm greeting!
. . .

Edit1: It won't allow me to edit the post, so I assume this means you have a nifty feature that removes the post from view . . . in the future I will edit it and add the answers . . . .
You're welcome

You assume wrongly. We have a nifty feature which prevents non‑mods editing posts after a certain age. And there is a good reason for it. After a post has been replied to, any changes make the replies look like nonsense. Any new material belongs in a new post, please.
 
Blake Boyd
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:
Blake Boyd wrote:Thank you very much for the warm greeting!
. . .

Edit1: It won't allow me to edit the post, so I assume this means you have a nifty feature that removes the post from view . . . in the future I will edit it and add the answers . . . .
You're welcome

You assume wrongly. We have a nifty feature which prevents non‑mods editing posts after a certain age. And there is a good reason for it. After a post has been replied to, any changes make the replies look like nonsense. Any new material belongs in a new post, please.


I really like the way this forum was designed. 'Tis a step above your average place of internet congregation. Please delete my first post and the ones that came after up until my "Revised collection of all posts" 1 post above. I will remove this message by Edit (moderator Request) after you see it. Thanks.
The post that shall remain intact is below. It's basically just the Q&A I slapped on the end of that huge behemoth above, separated because I'm rather sure this section will grow as I add answers to the questions for others who may be reading this post looking to do anything remotely similar. I hope you see it as a decent idea too... because it probably needs to be it's own fresh paragraph. ^^. Oh, in the future when I add answers to the questions, assuming the forum flags it as replied to, I'll ask your help in posting the answers here.

Questions and Answers
A. What is the Java equivalent of a "setup" or single-run "loop" placed at the top of the program? (unknown)
B. What is the Java equivalent of declaring a float, integer, and string variable? (unknown)
C. In Java, how does one assign one value to multiple variables? Must a new line be added for each value to each group? (above I use the format: int [a, b, c] = 1; [d, e, f] = 2;) (unknown)
D. Does java have a plugin or "library" that allows one to use simple commands to:

1. Load a .txt file, or word containing file of other extension? (above I use the format: load library(path to file);) (unknown)
2. Allow the programmer to target or load a word from that text file for additional review? (above I use the format: load word(word#);) (unknown)
3. Allow the programmer to target or load a letter from that word? (above I use the format: load letter(letter#);) (unknown)

E. Does java allow you to check an integer variable to see if it is a single digit? If so, how? (above I use the format: if currentSum != 1digit) (unknown)
F. If the prior question is yes, does Java have a command that allows you to split an int var into its separate digits for maths? (above I use the format: currentSum = the digits of currentSum added together; which is human speak) (unknown)
G. Does Java allow one to break from a loop, for instance an if or else statement? If so can one break to the main loop? (above I use the format: break; or: break to void loop(); or break to looptitle();) (unknown)
H. What are the various commands for printing a message, whether they be to window, cmd prompt window, or box with 'ok' prompt? (above I use the format: print "string") (unknown)
I. How can strings be stored consecutively or in any order for use at a later time? I believe these are called arrays, if so, how do they work in Java? (unknown)
J. Does java have a plugin or "library" (perhaps the same one asked for above) that allows one to save the values of a particular array (or string-storing block if they aren't called arrays) to a .txt document in the root directory of your program? (unknown)
K. When embedding a variable inside a string, what is the proper syntax used so the program reads it correctly? (Above I use the format: wordorstring'variable'; where if 'variable' = 1, the machine reads wordorstring1) (unknown)
L. What is the proper way to take one variable and set it equal to the other, without accidentally doing it the opposite way around. (Above I believe I was inconsistent.) (unknown)
M. What is the proper syntax for adding your own function (or loop) within the main loop? And how might one jump to it from a code block? (Above I use the format: functionorloopname() {})(to jump I simply list it: functionorloopname();)

I believe this covers all questions in my mind, the lack of answers to which are the only barriers stopping me from completing my first Java program, or you can think of it as my slightly elaborate "hello world!". With these questions answered, I will have the power to do very many things with this lovely language, as most of what I do when programming evolves around these simple concepts. Again, if some of these questions offend you for their simple-ness, you can withhold replying and will likely find I answered them for myself or received aid from someone who doesn't mind, so please don't take any offense to my complete lack of knowledge.

Future Features you may find in detail Here:
1. Adding a simple GUI, in terms of the project above, allowing the user to select which file they want to load by means of a browse window, and also allowing the user to choose which directory they would like the output files.
2. Adding the ability to display numerical data attached to strings or photos, or any noun really into simple graphs, flow-charts, or other helpful graphics.
3. Learning of ways to further process numbers and maths; I have a suspicion I will be doing more complex calculations of the numerological values of words, whether that means storing all 9's that pop up while number crunching in their own slot next to the 'final word value' or maintaining integrity of any number for that matter the user doesn't wish to add to the final sum. This is simple to do, yet placed here as it is on the "wishlist" and goes above "minimal functionality". (An example of what I mean, say the user doesn't want 4's added, while crunching the word CAT or 312, the program would display 42 as opposed to 6.)(Another example, user doesn't wish the number 3 to be added in the word Library aka 3929197, the program will display 337 as opposed to 4. The value of the word doesn't change, but certain numbers once reached, or even those present in the letters without addition themselves would be withheld from the last value)(One final example differentiating the last bit I had to add to this with the word Lilly; the program withholds addition of any letter with a value of 3, so 39337 becomes 3337.)
3b. This step is only really useful to me, but showing how I added complexity at various processes of the number crunching may help some I imagine trying to do projects that for one reason or other must withhold certain values while + - x or /ing.
 
Campbell Ritchie
Marshal
Posts: 56553
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Blake Boyd wrote: . . . Please delete my first post and the ones that came after . . . I will remove this message by Edit (moderator Request) . . .
We don't delete posts unless we think there is something wrong with them, e.g. spam, offensive language. Duscussed here.
 
Campbell Ritchie
Marshal
Posts: 56553
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Blake Boyd wrote: . . . I really like the way this forum was designed. . . .
Thank you.
A. What is the Java equivalent of a "setup" or single-run "loop" placed at the top of the program? (unknown)
I ahv never heard of a setup or a single run loop. Do you mean a single‑line statement, or a constructor. You use constructors to initialise objects' state.
B. What is the Java equivalent of declaring a float, integer, and string variable? (unknown)
Don't use float; use BigDecimal or if you can cope with imprecision double. You should find something about declarations in the Java Tutorials. It will be in the basics section somewhere.
C. In Java, how does one assign one value to multiple variables? Must a new line be added for each value to each group? (above I use the format: int [a, b, c] = 1; [d, e, f] = 2;) (unknown)You don't. Each value is assigned individually. Look through this forum for how to get chars out of an array. You may be able to write an array which does that but backwards.

D. Does java have a plugin or "library" that allows one to use simple commands to:

1. Load a .txt file, or word containing file of other extension? (above I use the format: load library(path to file);) (unknown)
Yes; it should be in this tutorial somewhere.
. . .
E. Does java allow you to check an integer variable to see if it is a single digit? If so, how? (above I use the format: if currentSum != 1digit) (unknown)
You mean whether it is greater than 0 and less than 10?
F. If the prior question is yes, does Java have a command that allows you to split an int var into its separate digits for maths? (above I use the format: currentSum = the digits of currentSum added together; which is human speak) (unknown)
I had to do that as a beginner with the basic arithmetic operators: see first tutorial link somewhere. we had to get all the individual digits.G. Does Java allow one to break from a loop, for instance an if or else statement? If so can one break to the main loop? (above I use the format: break; or: break to void loop(); or break to looptitle();) (unknown)Yes, with break continue or their labelled versions, but I don't like those constructs
H. What are the various commands for printing a message, whether they be to window, cmd prompt window, or box with 'ok' prompt? (above I use the format: print "string") (unknown)
If you didn't come across that in the basic tutorial links, I shall be very surprised. Look for option pane in the tutorials.

I. How can strings be stored consecutively or in any order for use at a later time? I believe these are called arrays, if so, how do they work in Java? (unknown)
You should have seen an arrays section in the tutorials by now. Also look for the collections “trail”.

J. Does java have a plugin or "library" (perhaps the same one asked for above) that allows one to save the values of a particular array (or string-storing block if they aren't called arrays) to a .txt document in the root directory of your program? (unknown)
You should have seen such a section in the tutorials by now.

K. When embedding a variable inside a string, what is the proper syntax used so the program reads it correctly? (Above I use the format: wordorstring'variable'; where if 'variable' = 1, the machine reads wordorstring1) (unknown)
Probably, but that sounds like bad use of Strings.
. . .
M. What is the proper syntax for adding your own function (or loop) within the main loop? And how might one jump to it from a code block? (Above I use the format: functionorloopname() {})(to jump I simply list it: functionorloopname();)
They are not called functions but methods. You should have seen that in the tutorials by now, otherwise myMethodName(...);

. . .
t looks to me that your are biting off more than you can chew. You need to program the same way you eat an elephant.
 
Blake Boyd
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A. What is the Java equivalent of a "setup" or single-run "loop" placed at the top of the program? (unknown)
I ahv never heard of a setup or a single run loop. Do you mean a single‑line statement, or a constructor. You use constructors to initialise objects' state.


Thank you! This is very helpful. I guess in this sense the "setup" I am familiar to is simply a standard declaration before the code, or as you put the constructor. I come from a background mostly in Arduino/ stamp-based programming. But the arduino in particular has one define their variables first, and then configure their values and execute any code they wish to only do so once (like pre-loading this or that) in a "loop" called setup that only plays through once and immediately proceeds to the main loop. I guess they did this so that those often times numerous bits of code one has to execute to get their project "loaded" and running, don't cloud the bulk of the program. This was C or C++ based so the ability to be as organized as one using Java was never available.

At the same time, one could always just write their own function/method and replace the "setup.loop()" entirely in the aforementioned language, but again, I think they were going for newb-friendliness to reach the most people. At that point, I am excited to be learning Java, because now that I have earned my "beginners wings" I am very ready to take up a language that offers far greater flexibility and control.


. . .
E. Does java allow you to check an integer variable to see if it is a single digit? If so, how? (above I use the format: if currentSum != 1digit) (unknown)
You mean whether it is greater than 0 and less than 10?


LOL. I really did. I haven't meant an l.o.l. online in a very long time. I can't believe something so trivial could escape me as a solution when I gave this specific line of code so much thought! You are a life-saver.

F. If the prior question is yes, does Java have a command that allows you to split an int var into its separate digits for maths? (above I use the format: currentSum = the digits of currentSum added together; which is human speak) (unknown)
I had to do that as a beginner with the basic arithmetic operators: see first tutorial link somewhere. we had to get all the individual digits.

This is an answer to what has become the must troubling of all questions for me. You have no idea how much this means to me.


H. What are the various commands for printing a message, whether they be to window, cmd prompt window, or box with 'ok' prompt? (above I use the format: print "string") (unknown)
If you didn't come across that in the basic tutorial links, I shall be very surprised. Look for option pane in the tutorials.


I as a matter of fact did. I think I mentioned somewhere up there in that wall of words that I was going to list all my questions at that point so my answers could be of use to others later. Regardless, I really appreciate the fact that you care to give a response to those questions, "no matter how small".



K. When embedding a variable inside a string, what is the proper syntax used so the program reads it correctly? (Above I use the format: wordorstring'variable'; where if 'variable' = 1, the machine reads wordorstring1) (unknown)
Probably, but that sounds like bad use of Strings.


A very helpful link.

. . .
M. What is the proper syntax for adding your own function (or loop) within the main loop? And how might one jump to it from a code block? (Above I use the format: functionorloopname() {})(to jump I simply list it: functionorloopname();)
They are not called functions but methods. You should have seen that in the tutorials by now, otherwise myMethodName(...);


Exactly as I suspected. There is no difference between my language of most familiarity and java at this point. @ #must'veBeenInTheTutorials I did indeed see it. You may have noticed I used the word method above, without having read this yet. ;)

. . .

it looks to me that your are biting off more than you can chew. You need to program the same way you eat an elephant.


I beg to softly differ my friend, but I do take your words to heart. It is true that one should eat their elephant slowly, and with a few grains of pepper and salt I might add for flavor, but I think of this program as a "hello world". When approaching how I was to code it, I knew those things I already could do, and those things that would take learning. I feel like emphasizing once more that only 3 of those questions above, at the most, I felt I would actually require assistance with. The rest was mere translation coming from my background into a new language, so I understood the functionality behind the scenes (albeit sometimes under different names and commands) yet lacked the syntax. Upon beginning to write that list I decided it best to just put every Q that was in my mind at that instant down, in hopes that my learning process could jump-start another who visits this thread. I dearly hope this was the right decision and that I didn't pester you any. :/ And as I said, there was a disclaimer that read something along the lines of "feel free to answer the difficult ones and leave the easy stuff to me", but I believe I edited it out to form the "revised new and improved shorter word count" edition below. :s Grr, well...

With that said, I am ever so very appreciative with you taking your time like you did to reply to every small detail. I find it amazing that one can actually get that kind of support on the internet, as usually an answer is in the form of a few words targeted at a specific question, not quite so full and not quite so complete. I think it's one more of those reasons I know deciding to sign-up to this community for help was the best decision among all alternatives. I will heed today's result and leave off minor questions in the future, because in the end, the real purpose of my post is not to become bloated with minor details that might assist another, but to find solutions to my own problems in a timely manner and concise format. Posts bloated with minor details are best left to tutorials written by those experienced in the language. I am but learning of the ways, I promise <3

I'm actually amidst a busy schedule today, but had a few moments to come on and respond and I am very glad I did. I will be updating the "answers and questions" list when I find a spare moment, and finally be compiling, all thanks to you. ^.^

Oh, and while you do not delete posts, might you consider editing the two above that are identical to the two below in all ways except the latter being more concise and easier to follow? A simple "ModEdit: OP revised structure of first two posts to be more concise below" at the top of each would suffice. Either way you have been more than enough help and left me nothing but Satis.

Good night to you and any who may be reading,
-Blake
 
Campbell Ritchie
Marshal
Posts: 56553
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Blake Boyd wrote: . . . But the arduino in particular has one . . .
One thing you have to do when learning a new language: forget the old language. Otherwise it simply causes confusion
You are a life-saver.
. . .
and you have got me all embarrassed about that.

No time to answer the other points at the moment, I am afraid.
 
Campbell Ritchie
Marshal
Posts: 56553
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Blake Boyd wrote: . . . LOL. I really did. . . .
. . .It is surprising how one can trip over something simple. Everybody does that from time to time.
A very helpful link.
On behalf of whoever wrote that FAQ, thank you
. . . mere translation coming from my background into a new language, so I understood the functionality . . .
The functionality you require is the same if you change language, but the syntax and idioms you use to achieve it are sometimes different. I have seen no end of confusion and errors because people think, “XXX means that in language Y, so it means the same in Java.” The language which seems to cause the most frequent confusion is C++, but I have seen dangerous confusions between Java and C#, too.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!