Programmers of Sup Forums

Programmers of Sup Forums,
What would you do to make this use dialog based input and output? I cant figure it out no matter what I do its not working.

don't use Java, do use c++

also fuck off with your entry level Comp Sci homework

Well its for a uni assignment I have no choice.

Either not use java or use java's Swing UI library.

But all you need it to do is add them and print it right?

What is the Swing UI library?

What are you even confused about, are you retarded? Or does the printed code not work?

>java

Unless you arent allowed to use UI and are just asking how to parse a string for 2 separate inputs. If the latter is the case, just prompt for both numbers, scan the input in as a string, then create a new scanner passing it that string and scan in the separate numbers to a variable.

The project is asking me to use this setup but somehow use words instead of numbers and it's got me stumped, maybe I am just retarded then.

Its a java library that has UI objects like popups or option windows but it sounds to me like you are just wanting something way simpler. Are you just trying to ask for both inputs at the same time rather than prompting for it twice or what exactly are you trying to change this code to

>diaLOG

see

Underrated post.

So instead of entering numbers for lines 8 and 11, they want you to input stuff like "two" or "twenty"?

fuck if I know they just told me to change it to use words instead of numbers I guess that's it. This is the only part of the project I really don't understand everything else seems easy.

int sumdiddlyum;
for(theirOwn = string.cheese){
sumdiddlyum += number;
}

Wadu hek?

Welp hard to help if you dont even know what its supposed to do in the first place. Would help if you were provided test cases so you can see what input to use when running it.

In any case, if thats what you are supposed to do then number1 and number2 will have to be strings. Then you will need a method that has a shitton of if-else statements to translate the words into their respective numbers while reading the string. IE translating one thousand two hundred and four would have to set the output number to 1x1000 + 2x100 + 4 as it reads that string of the number

I understand what the basic program is supposed to to I'm not that retarded. I just can't figure out what they wanted me to do to modify it I am more of a show me type of learner but they just told me to study this code then figure out how to modify it I'm just gonna forget about it and keep moving seems pointless anyways.

are you saying you want to use pop up dialog boxes for input/outputs?

Nope, thats what I thought he wanted and suggested Swing pop ups but sounds like he meant dialogue instead of dialog

like... somehow it would take fortytwo and translate it to 42?

why?

shit yeah my bad I tried using JOptionPane and they told me that was not what they wanted but I am just saying screw it and moving on I don't care about some lost points, but do you guys know any good tutorials I am more of a show me type of person and reading from a book is the worst when I can't really see whats happening.

No clue but it sounds like thats what they want according to his confusion since he said they want to take words as inputs. Thats just some tedious work to do that crap. Unless theres a library that does it, id say thats a 50ish line if-else or switch-case statement

Replace %n by \n in the format string for printf. You want \n for newline rather than specify a second format argument that does not exist.

Ya, most cs books are just theory crap. Not sure about videos for one-off concepts like these but after a while of programming youll come to find google and stackexchange to be your best friends. Just googling "convert words to numbers java" comes up with plenty of posts on stack with example code approaches.

Oh ok well cool thanks, Ill try stackexchange out.

Sure thing, that site got me through most of my issues when I was in years 1-3 of uni. For the harder classes the replies tend to get very complicated and abstract unfortunately and it becomes better to just read a book at that point

C'mon, seriously? Just replace that % by \ and you are done...

What do if you want a goat? Asking for a friend.

Op is a mongoloid retard however compared to a log faggot he is goddamn Max Planck.
Log faggot you are the cancer killing/b/
kindly die

...

It is so obvious...

thats your average log faggot anons too stupid to come up with a decent insult
too lazy to kill himself

...

%n is a format converter for java's printf method that oracle says to use over the \n escape sequence for compatibility reasons. So no, thats not fixing anything

this guy is right,
but use a FUCKING CASE STATEMENT. Jeez,

Ya, I said in a later post itll be either a long if-else or switch-case but just said to use the if-else based on how noob the OP sounded

yeah ok,
could be simple like.
one -nine
hundred
thousand

so not as big as it might need to be,
he will likely need a parser to parse the input but yeah as you said if he is that noob hes fucked now anyway.

Sup Forums is not your personal army
abandon thread, bitch you got more than you deserve and still can't figure it out.

yeah I appreciate your help too, I already said I'm just gonna keep moving on though I don't understand fully what they want and all they keep telling me to do is modify the picture i put up. If you have any good tutorials on Java that you know of I'd appreciate it though I hate just reading out of a book.

Hey now I have been appreciative to everyone in this thread without being some asshole I was just asking for help not the whole answer, but its on its Sup Forums the attitude is expected.

dude.
we gave you all you need.

you need one string parser and a case statement.
fucking use google that will take you to stack overflow. fuck me. do you want someone holding tour hand down the rosemary path all your fucking life. grow a pair.

Whoops, you're right.
Then it is

number1 = Integer.valueOf(JOptionPane.showInputDialog("Enter first integer:"));
number2 = Integer.valueOf(JOptionPane.showInputDialog("Enter second integer:"));

...

and finally

JOptionPane.showMessageDialog(null, String.format("Sum is %d", sum));

Well thanks I'll get it from here then.

sure kid keep sucking the shit out of a scenester's 50 yo asshole
>seriously this is a retarded thing you are doing all we do it point at you retards and laugh

> posting pictures of code
> being this noob

...