So simple. Sometimes asking a question will help my brain ignite to solve a problem. Thanks for responding.
Type: Posts; User: Nuggets
So simple. Sometimes asking a question will help my brain ignite to solve a problem. Thanks for responding.
How would you keep track of how many times a program has ran through a loop? For example, program asks user to continue (y/n), if they enter y, program continues then asks again once finished with...
Oh, for some reason when I was compiling, it kept printing out "BALL". So I add the nested for loop to see if that would work. I didn't change anything but remove the nested for loop again. Hm, now...
Modified my for loop. I input "BALL" and now it outputs, "CCCCCCCCCCCCCCCCCCCCCCCCCCBBBBBBBBBBBBBBBBBBBBBBBBBBMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM". It did increment each character by...
The print statement is printing out the string that I input, which is "BALL". The value of i is found when binarySearch looks for the characters that is entered in as input. I have searched the input...
System.out.print(Alphabet[i+1]);
I came up this statement. I would print the result in the array Alphabet + 1 so it would increment it by one. But its not working. Can you help me?
Modified For loop by adding in charAt method. It now prints what I input in letters. How would I increment the value of the input so it shifts one position to print out the next alphabet character? I...
[QUOTE=andreas90;62722]You do that with your for loop if i'm getting it right.
Yes, but I have to set the variable char value to something. Like how I set char value = 'C' and it found the...
This is getting frustrating. I modified char value = 0; and changed it to char value = 'C'. Now System.out.println(result); will output 2, which is the correct value in my char Alphabet array. How...
Well, if I do system.out.print(result + 1); it will print out 0 instead of -1.
My value variable is set to equal 0. That's all I've done with it. It gives an error when I compile without the = 0.
So why isn't it only returning -1 as the index for my system.out.print(result).
int result = Arrays.binarySearch(Alphabet, value);
This code searches for a character in the Alphabet array, then assigns it a value correct? If not, can someone please explain to me what...
So i need to create that code for every letter in my array from A to Z? I want this program to input any string of letters, like "BALL" then increment each one of those characters to the next letter...
if (result < 25) {
System.out.println("val" + result);
Output: val-1
val-1
val-1
if (result == 25) {
System.out.print(Alphabet[0]);
Output: gives an exception on line 22.
All it prints out is -1-1-1 for "ABC".
I'm entering in a txt file to convert. I thought this statement was supposed to sort the array, then search the binary number for the character. Thus I then did the if (result < 25), meaning if the...
I want this program to search the user input for a character stored in an array, then increment the value of the character by 1. For example, if the input was "A", then increment that value by 1 so...
Output a new file.
What method would I use to rename a file that has been entered? For example, I input a txt file named "test.txt", the program reads that file. Then it will output the file under a new name.
Thank you.
Here is newly modified for loop.
for (int pos = line.length() - 1; pos >= 0; pos--) {
for (int i=0; i<alphabet.length; i++) {
if (alphabet[pos] != 'Z') {
alphabet[pos]++;...
I changed println to print and it prints horizontally now. But why is my code printing my output backwards? For example, Input: "ABC", Output: "DCB". I want it to print in the same format as the...
Here is my modified for loop. I think I have almost solved this problem. Input example, "ABC". Output example is exactly as shown:
"D
C
B"
How would I change it so it prints horizontally like...
That helped a lot, thanks! I think what Aussie said made sense though. I need to take the input, rather than the array. I modified code again. Output keeps looping through the array elements and...