d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Returning A Char Class Problem > *need Help It's Due At 12*
12Next
Add Reply New Topic New Poll
Member
Posts: 9,274
Joined: May 4 2010
Gold: 0.01
Mar 15 2013 07:42pm
I need to return the input of the user, but I'm getting a error when I put.

return input;

the getOperator() must stay a char because of the rest of the code; plus my professor wants it that way.

Any ideas how I would go about doing this?

Code
 

char getOperator()

   {
       System.out.println("Enter operation: + - * / q (q ==> quit) : ");
       String input = scan.next();
       return 0;
       
   }



Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Mar 15 2013 07:54pm
food for thought. what happens if they input something like "asldkfjasldfkjaldskfj" instead of just *? ignoring the technical problem for the moment, whats your logical plan to convert that long string into a single char? or on a more technical side, what is a string? it's clearly not a primitive like char is. the source code is available too.

hint: look at all the methods available to a string and see which returns a char. if you're using an IDE, type input. and ctrl + space to see what methods are available. if you don't have an IDE, then look online.
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Mar 15 2013 08:34pm
still trying to figure out why a method which is supposed to return char uses a string var inside as the return o.O
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Mar 16 2013 02:51am
Quote (Eep @ Mar 15 2013 10:34pm)
still trying to figure out why a method which is supposed to return char uses a string var inside as the return o.O


you have bigger problems then that if you are trying to understand that.

the bloody function isnt even returning a char but rather a nullbyte '\0' and how on earth do you read it as returning a string when its returning a fixed nullbyte value...? god you should just stop posting until you actually know what youre talking about.

@op change your input to a char and then use a scanner to accept a single character. then return your variable. simple as that.

This post was edited by AbDuCt on Mar 16 2013 02:52am
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Mar 16 2013 04:00am
Quote (AbDuCt @ Mar 16 2013 03:51am)
you have bigger problems then that if you are trying to understand that.

the bloody function isnt even returning a char but rather a nullbyte '\0' and how on earth do you read it as returning a string when its returning a fixed nullbyte value...? god you should just stop posting until you actually know what youre talking about.

@op change your input to a char and then use a scanner to accept a single character. then return your variable. simple as that.


still mad cause of that suspension huh

best be watching your blood pressure

I say this out of pseudo legit concern

This post was edited by Eep on Mar 16 2013 04:02am
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Mar 16 2013 01:05pm
Quote (Eep @ Mar 16 2013 06:00am)
still mad cause of that suspension huh

best be watching your blood pressure

I say this out of pseudo legit concern


what suspension? you mean that one that i got for like 2 hours while i was sleeping?

you seriously can not code and then you go to help people by giving them bad advice or wrong advice. if you dont know what you are talking about just exit the thread for christ sakes.
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Mar 16 2013 09:50pm
Quote (AbDuCt @ Mar 16 2013 02:05pm)
what suspension? you mean that one that i got for like 2 hours while i was sleeping?

you seriously can not code and then you go to help people by giving them bad advice or wrong advice. if you dont know what you are talking about just exit the thread for christ sakes.


what advice have I ever given recently that I haven't caught myself on being wrong? There have a few occasions where I told someone to maybe check over something. In fact there was one recently and the OP himself told me about it and that was fine. I haven't offered concrete advice.

example: this thread

http://forums.d2jsp.org/topic.php?t=66747129&f=122

I was wrong, obviously, but I didn't tell him to make any changes to his program.

This thread, for example. I didn't tell the OP to change anything, I was merely stating my own curiosity.

In BOTH cases, however, you have gone out of bounds and beyond merely telling me I am wrong, you have gone so low as to throw out these personal attacks.


It wasn't too long ago that you were actually helping me with some of my problems and you were a nice contrast to irimi/carter. Now you just spend your days finding ways to be angry at people on the internet.

So again, check that blood pressure, sort your shit out IRL so you don't have to vent on here.


@OP: Sorry for the spam.
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Mar 16 2013 10:59pm
Quote (Eep @ Mar 16 2013 11:50pm)
what advice have I ever given recently that I haven't caught myself on being wrong? There have a few occasions where I told someone to maybe check over something. In fact there was one recently and the OP himself told me about it and that was fine. I haven't offered concrete advice.

example: this thread

http://forums.d2jsp.org/topic.php?t=66747129&f=122

I was wrong, obviously, but I didn't tell him to make any changes to his program.

This thread, for example. I didn't tell the OP to change anything, I was merely stating my own curiosity.

In BOTH cases, however, you have gone out of bounds and beyond merely telling me I am wrong, you have gone so low as to throw out these personal attacks.


It wasn't too long ago that you were actually helping me with some of my problems and you were a nice contrast to irimi/carter. Now you just spend your days finding ways to be angry at people on the internet.

So again, check that blood pressure, sort your shit out IRL so you don't have to vent on here.


@OP: Sorry for the spam.


i help anyone who needs help but others who think they are helping when they know nothing about the subject is merely irritating. overall if you dont know what your talking about dont post.

if you made a thread for help id give you help but for the sakes of everyone here just shut up if youre not sure about what youre saying even if it is your own observments. the op doesnt need to know what you think and we dont either. it isnt helping anyone any.

edit:: and posts like "still trying to figure out why a method which is supposed to return char uses a string var inside as the return o.O " makes you look like an ignorant prick who thinks he knows what he is talking about, whilst your just pulling shit out your ass. doesnt make you look any better to us nor help anyone.

This post was edited by AbDuCt on Mar 16 2013 11:00pm
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Mar 17 2013 12:15am
Quote (AbDuCt @ Mar 16 2013 11:59pm)
i help anyone who needs help but others who think they are helping when they know nothing about the subject is merely irritating. overall if you dont know what your talking about dont post.

if you made a thread for help id give you help but for the sakes of everyone here just shut up if youre not sure about what youre saying even if it is your own observments. the op doesnt need to know what you think and we dont either. it isnt helping anyone any.

edit:: and posts like "still trying to figure out why a method which is supposed to return char uses a string var inside as the return o.O " makes you look like an ignorant prick who thinks he knows what he is talking about, whilst your just pulling shit out your ass. doesnt make you look any better to us nor help anyone.


In your OPINION it makes me look like an 'ignorant prick'. (another fine use of our lovely English language btw)

If you would have READ the first post instead of just his code, you would have seen:

Code
I need to return the input of the user, but I'm getting a error when I put.

return input;


ergo, at some point, he was trying to return the variable INPUT, and that is what I was confused about. You focused on the line with the return 0;

You think you are doing people a service but in reality, the one with the ignorant tone is YOU. Do I really need to quote some of your gems from recent threads?

Quote (AbDuCt @ Feb 19 2013 03:30pm)
are you seriously that retarded that you can write this much code and not know how to do this?

declare an integer value and simple increment it based on what you want. aka if you want correct questions answered you would put the incremented variable after the printf statement saying correct.

also if you dont know how to increment an integer its simple

Code
varname++;




Quote (AbDuCt @ Mar 13 2013 02:11am)
same concept as using the `new` and `delete` keywords in c++. youre still retarded.


Quote (AbDuCt @ Mar 13 2013 01:35pm)


and lol i got a flaming suspension for making this kid look dumb :/


etc etc

you are a fine example of an 'ignorant prick' and now you are a 'hypocrite'. You do nothing but flex your own ego and talk down to people under the guise of 'helping'.

And if you think that for some reason you are privileged to do that because you know more than us, you aren't. If you think it is okay because its some internet forum, you are wrong.

So go on and tell me more please.
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Mar 17 2013 12:35am
Quote (Eep @ Mar 17 2013 02:15am)
In your OPINION it makes me look like an 'ignorant prick'. (another fine use of our lovely English language btw)

If you would have READ the first post instead of just his code, you would have seen:

Code
I need to return the input of the user, but I'm getting a error when I put.

return input;


ergo, at some point, he was trying to return the variable INPUT, and that is what I was confused about. You focused on the line with the return 0;

You think you are doing people a service but in reality, the one with the ignorant tone is YOU. Do I really need to quote some of your gems from recent threads?









etc etc

you are a fine example of an 'ignorant prick' and now you are a 'hypocrite'. You do nothing but flex your own ego and talk down to people under the guise of 'helping'.

And if you think that for some reason you are privileged to do that because you know more than us, you aren't. If you think it is okay because its some internet forum, you are wrong.

So go on and tell me more please.


second quote i told him how to fix his code (notice the varname++? well thats exactly what he needed to do to keep track of his correct answers and then he proceeded to post silly questions. in the end he did it like i said anyways) and he ignored it like every other post people gave him on how to fix his problems, because the kid wants direct code fixes and expects us to debug and post back working code. i as well of others have gave him solid advice on how to fix his code but he forever seeks to do it his way and then asks again for help when it doesnt work.

third quote is you being retarded. malloc and free is the same concept as new and delete, which is used in c++ so your excuse of "i dont work with c enough" is void... so if you do not know what you are talking about then dont post. how often do you see me post in a thread if i dont try to offer concrete ways to fix things. in that thread i told him to run the application in a debugger with the binary compiled with the -g flag and check to make sure the addresses are what they are supposed to be. in that same post you go talking about freeing memory and such then at the end "uh yea i dont actually know c cuz im no master so i dont actually know what im talking about"

what does fourth quote have to do with anything?

if you would of read my reply you would also have noticed i told him how to fix his string error. please reply back this is mildly entertaining.

edit:: notice how i only tell you that you are a stupid kid while everyone else seems to get nothing on complements from me? well... thats because they actually know what they are talking about and dont post stupid shit like "well uh i think uh your loop is not looping and uh yea thats me own uh observation" (mimic of eep please dont make me go back through posts to find lots of examples where you make stupid comments like this. hell theres one in this topic.)

This post was edited by AbDuCt on Mar 17 2013 12:45am
Go Back To Programming & Development Topic List
12Next
Add Reply New Topic New Poll