Yea,also a little typo from me.
public class test {
public static void main(String[] args) {
System.out.println(isPower_recursive(2,16));
}
Type: Posts; User: arhzz
Yea,also a little typo from me.
public class test {
public static void main(String[] args) {
System.out.println(isPower_recursive(2,16));
}
I found online how to transform iteration into recursion,followed the guide (its literally a pattern you have to follow).And I solved the problem.For those are interested;
public static...
Actually I've solved it already,like this.I dont need to solve it recursivly I want to solve it recursivly.To be precise I want to be able to "transform" iterative code into recursive,to figure out...
Hello!
Consider this code
public static boolean isPower(int x, int n) {
if (x == 1)
return (n == 1);
If you want to use the word apple as char and not a string you have use ' ' and not " ".
Thank you,and also thank you for your help!
It worked just fine.Is it not working on your end?
Oh okay,I didnt know I could do that.I'd assume this is the way
import java.util.Arrays;
public class test {
public static String[] splitString (String s) {
return s.split (" ");
Getting this error test.java:14: error: cannot find symbol
return savedWords;
^
symbol: variable savedWords
location: class test
1 error
But what are my savedWords and what is my newWord? How do I "access" them ?
I can return them any way I would like,I'd prefer the easiest solution.
import java.util.Arrays;
public class test {
public static String[] splitString (String s) {
return s.split (" ");
}
public static void wordsOfLength(String words,int length) {...
11 is the count of the chars in the text.
Well I'm aware that the program,when it entcounters a white space it should register that we have found a word.Not really sure how to do that.
import java.util.Arrays;
public class test {
public static String wordsOfLength(String words, int length) {
int cnt = 0;
String foundWords = "";
for(int i = 0; i < words.length(); i++) {...
So my step by step solution
1.Read in the text and the length
2.Go through the text and find the length of the first word(than the second,third...)
3.Check if the length of the first word is the...
Hello!
What I need to do is given a input of a random text and a certain length,from the user I need to find all of the words in that text that have that length and return them. For example we...
Yea I see it as well, the values of the char are single digit that is why its always printing true.Which means my logic wasnt at fault but the readChar() method.Thank you for your help,I'll adjust...
Okay,very very interesting results;
for 12;
12
ch=49 1
true
for 8
At what point in the code do I want to see the value of ch? When the user inputs the value?
Hello!
Consider this code
import java.util.Arrays;
public class test {
I'll give it a shot,thanks for the suggestion.
I kind of want to avoid doing that,but I guess there is no other way.
EDIT: Okay so I was right for f(3) and f(12).But for f(0) I was wrong,it should be like this;
f(0) = c f g
And I am not...
Well I already did that,and I've posted what I think would come out for the diffrent values of x.I've redone the task and I think it should be right. What do you think?
Hello !
Consider this code;
void f(int x) {
try {
g(x);
Oh wow,that is embarassing,quite a silly mistake.It works just fine now thank you!