#Code that transform a string that may contain double values and letters in to integer
126 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @torn jewel! Please use
/closeor theClose Postbutton above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
you didn't need to close the previous thread tbh
I added the if statement here aswell
yes i did
you didn't
again, you didn't
if you're trying to get an integer, why not just use parseInt
...ok? im saying you didn't need to close it, you couldve just used that thread
and use hasNextInt or catch the error
you can't get non-integers with the replace you have anyways, since the . gets removed
i don't think it'd make much sense to input 3.0 and get back 30
No I get 3.0
you don't
it doesn't
% does division. you can't do % 0
that's not what i said
im saying if you input 3.0, you get 30
do you want integers only or not
let me explain why i am doing this
then use parseInt/hasNextInt/nextInt instead of all your double stuff
if you want integers, then use the integers
don't attempt to fix the given value, just treat it as is and if it doesn't work then it doesn't work and prompt the user again
why does my program work when I say length%0 == 0
it doesn't, and you aren't
you're doing % 1
oh huh you are
didn't read the entire thing
only when I say %0 it works
that's because you're short-circuiting and it never actually evaluates teh % 0
when I put %1 it doesn't
@idle rover I only received java(15.0.2) error output
Exception in thread "main" java.lang.ArithmeticException: / by zero
at temp.main(file0.code.java:2)
Here is your java(15.0.2) output @idle rover
NaN
because you have a ton of issues
and you stumbled upon a combination of issues that looks like it works but actually fails horribly
but the system output is 3
yeah sure
please stop
if you think you know that your program works, then why are you asking here
you keep denying what im stating
you.. didn't really see it
you only saw the output
int n = input.nextInt();
System.out.println(1);
```this program finds the factorial of `n`, i tested it with `0` and `1`
there's not the solution, again, you have multiple issues
nope that's not the fix, the fix is rewriting it to actually do what you want it to do
I just wanted to see why %0 worked and %1 didn't and I got my answer length%1 is already = because I defined length = -1
look man if you're here to ask for help and then promptly ignore and deny and argue against everything the helpers try to tell you, this isn't the place for it
% 0 doesn't work. your code is too obscured for it to have an effect.
I asked 2 questions you gave me the answer to the first one and I thank you for that
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
you've ignored it lmao
no
.
aight you have fun in your echo chamber
I accepted what you said by saying ok
I just wanted to know why when I placed %0 it kinda worked
again, it doesn't
And I got my answer %0 is NaN so that means it's !(%0==0), and when I placed !(%1==0) it didn't work because -1%1==0 so the while didn't work
% 1 is useless anyways, you always replace shit to be integers
completely invalidating the parseDouble you use
dude. % 0 is a bigger issue than % 1. % 0 works less than % 1
You are right but I wanted to understand the logic behind it not only the solution
there's no logic
you discovered floating-point division
and you again did not find the solution
fuck this im not paid to argue with arrogance
I didn't display arrogance
I didn't say that you are wrong
simply that I've seen another issue
I even thanked you with that previous one
doesn't make you any better
But what I said was of a different nature
Even if I did your solution it still wouldn't work
lmao no
my solution is to rewrite it because your code is a mess
that is not a solution
see what i mean about arrogance?
ive told you this twice already
That I said that I had 2 problems
and once you said to use parseint hasnextint and nextint
I said that it's ok
then I just simply asked why %0 worked
and i said that it didn't, and i showed why. and here you are still saying that % 0 worked
I said my question
I understood now why it worked but didn't at the same time
ok man I don't waant to argue anymore
thanks again for the help
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
have a nice day